$ npm install existent
Check if one or more paths exist, promise-less.
const existent = require('existent')
existent('sheep.txt', (err, missing) => {
console.log(err.message) // "File does not exist: /cwd/sheep.txt"
console.log(missing) // ["/cwd/sheep.txt"]
})
// Takes an optional base path
existent(['a', '../b', 'c'], '/things', (err) => {
if (err) throw err // "2 files do not exist: /b, /things/c"
})
// Synchronous variant (returns boolean)
existent.sync('package.json', ['node_modules', 'chalk'])
// Assertion
existent.assert(['penguin.js', 'flamingo.js'], 'lib')
existent(path(s), [base], callback)
Asynchronous variant. If base
is provided (a string or array), it will be prepended to each path
. The callback receives three arguments:
existent.sync(path(s), [base])
Synchronous variant, returns a boolean.
existent.assert(path(s), [base])
Throws if one or more paths do not exist.
With npm do:
npm install existent --save
MIT © Vincent Weevers
© 2010 - cnpmjs.org x YWFE | Home | YWFE