glob2fp
v1.0.0
Published
Recursively extract/find/search non-glob (real/file/base) path from/in glob pattern or array of glob patterns using `is-glob`.
Downloads
5
Readme
Recursively extract/find/search non-glob (real/file/base) path from/in glob pattern or array of glob patterns using is-glob. Actually default returns
dirname
that isnt looks like glob. But you can provide another criteria.
Install
npm i --save glob2fp
npm test
Features
- get real path from glob pattern or array of glob patterns
- support defining another criteria, default is based on
dirname
(nearest non-glob dirname) - recursively lookup
glob2fp
For more use-cases see the tests Recursively extract real path from glob pattern
fp
{Array|String} glob pattern(s)opts
{Object} only availableoptions.criteria
functionreturns
{Array|String}
Example
var glob2fp = require('glob2fp');
glob2fp('a/b/c/???/e/*.*');
//=> 'a/b/c'
glob2fp('a/b/c/{foo,bar}/e/*');
//=> 'a/b/c'
glob2fp('a/b/c/foo/e/*.js');
//=> 'a/b/c/foo/e'
glob2fp('!a/b/**.{js,md}');
//=> 'a/b'
glob2fp();
//=> ''
Or array of glob patterns
glob2fp([
'a/b/c/???/e/*.*',
'a/b/c/{foo,bar}/e/*',
'!a/b/c/foo/e/*.js',
'a/b/**.{js,md}',
'a/{b,{c,foo},e/d}/*.{js,md,txt}',
'a/b/{c..e}/*.{js,md,txt}'
]);
//=> [
'a/b/c',
'a/b/c',
'a/b/c/foo/e',
'a/b',
'a',
'a/b'
]
Author
Charlike Mike Reagent
License
Copyright (c) 2014-2015 Charlike Mike Reagent, contributors.
Released under the MIT
license.
Powered and automated by kdf, February 10, 2015