@kwsites/file-exists
Synchronous validation of a path existing either as a file or as a directory.
Last updated 4 years ago by steveukx .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @kwsites/file-exists 
SYNC missed versions from official npm registry.

@kwsites/file-exists

Synchronous validation of a path existing either as a file or as a directory.

const { exists, FILE, FOLDER, READABLE } = require('@kwsites/file-exists');

// check for a folder existing
assert(exists(__dirname, FOLDER));
assert(!exists(__filename, FOLDER));

// check for a file existing
assert(!exists(__filename, FILE));
assert(exists(__filename, FILE));

// when no type is specified, both folders and files are allowed
assert(exists(__dirname));
assert(exists(__filename));

// alternatively specify both files and folders
assert(exists(__dirname, FILE + FOLDER));

// or just that the path is readable (can be either a file or folder)
assert(exists(__filename, READABLE));

Troubleshooting

This library uses debug to handle logging, to enable logging, use either the environment variable:

"DEBUG=@kwsites/file-exists" node ./your-app.js 

Or explicitly enable logging using the debug library itself:

require('debug').enable('@kwsites/file-exists');

Current Tags

  • 1.1.1                                ...           latest (4 years ago)

3 Versions

  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Total 3
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (11)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE