An option-laden utility which takes general glob-paths, delimited paths etc. and returns an array of absolute paths.
$ npm install concrete-paths --saveGiven a directory containing:
/stuff
/lib
file1.js
file2.js
/logs
log1.txt
log2.txt
/node_modules
/some-package1
foo.txt
bar.txt
/some-package2
foo.txt
bar.txt
/test
test1.js
test2.js
Then concrete-paths can be used in the following ways:
Please see the
globpackage's Glob Primer for more information with working with glob patterns.
const concretePaths = require('concrete-paths')
concretePaths('/stuff/**/*.js').then(
function(result) {
// Result:
// [
// '/stuff/lib/file1.js',
// '/stuff/lib/file2.js',
// '/stuff/test/test1.js',
// '/stuff/test/test2.js'
// ]
}
)Useful when working with values derived from environment variables.
const concretePaths = require('concrete-paths')
concretePaths('/stuff/lib/*.js;/stuff/logs/*.js').then(
function(result) {
// Result:
// [
// '/stuff/lib/file1.js',
// '/stuff/lib/file2.js',
// '/stuff/logs/log1.txt',
// '/stuff/logs/log2.txt'
// ]
}
)Mix-and-match delimited strings, globs etc. in an array of strings.
const concretePaths = require('concrete-paths')
concretePaths(
[
'/stuff/node_modules/some-package1/*',
'/stuff/lib/*.js;/stuff/logs/*.js'
]
).then(
function(result) {
// Result:
// [
// '/stuff/node_modules/some-package1/foo.txt',
// '/stuff/node_modules/some-package1/bar.txt',
// '/stuff/lib/file1.js',
// '/stuff/lib/file2.js',
// '/stuff/logs/log1.txt',
// '/stuff/logs/log2.txt'
// ]
}
)| Option | Type | Notes |
|---|
$ npm test