Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

check-files-exist

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check-files-exist

Checks if the given array of file selectors or single selector resolves to a file.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

check-files-exist

This small promise based node module checks a given string or array of strings to contain valid file selectors. The selectors could either be relative or absolute paths or even globs.

Syntax

var checkFilesExist = require('check-files-exist');

checkFilesExist(['files/a.js', 'files/*_c.js'], __dirname).then(function () {
  console.log('All files exist.');
}, function (err) {
  console.log(err);
})

Examples

Let's assume, we've got the following directory structure:

+ files
  -  a.js
  - b_c.js
  - d.js

Each of the following calls would resolve the promise:

checkFilesExist('files/*')
checkFilesExist('files/**/*')
checkFilesExist('files/a.js')
checkFilesExist(['files/a.js', 'files/d.js'])
checkFilesExist(['files/a.js', ['files/*_c.js']])
checkFilesExist(['files/a.js', ['files/*_c.js', 'files/b_*']])
checkFilesExist([['files/a.js'], ['files/*_c.js', 'files/b_*']])

The following would reject it:

checkFilesExist('')
checkFilesExist('files/_*')
checkFilesExist([])
checkFilesExist(['files/', ''])

Use in a build chain

Using this module in f.e. gulp is really simsple:


gulp.task('checkFilesExist', function() {
  return checkFilesExist([
      config.scripts.files,
  ]);
});

Working dir

node-glob provides passing a cwd working directory string. You could easily pass a string as a second parameter to have it passed to glob:

checkFilesExist('files/a.js', __dirname).then(...);

Keywords

FAQs

Package last updated on 11 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc