first-existing-path
v1.0.1
Published
Get the first existing path
Downloads
9
Readme
First existing path
Get the first existing path from an array of strings
Install
npm install first-existing-path [--save]
Usage
const firstExistingPath = require('first-existing-path')
firstExistingPath([
process.env.CONFIG, '~/.config', '.config'
], function(err, path) {
})
Or as a promise:
const firstExistingPath = require('first-existing-path')
firstExistingPath([
process.env.CONFIG, '~/.config', '.config'
])
.then((path) => {
})
Or synchronous:
const firstExistingPath = require('first-existing-path')
let path = firstExistingPath.sync([
process.env.CONFIG, '~/.config', '.config'
])
API
/**
* firstExistingPath
* Get back the first path that does exist
* @param {Array} paths
* @param {Function} cb optional callback
* @return {String|Boolean} Promise the founded path or false
*/
function firstExistingPath(paths, cb)
/**
* firstExistingPath sync
* Get back the first path that does exist
* @param {Array} paths
* @return {String|Boolean} the founded path or false
*/
function firstExistingPathSync(paths)
License
MIT