glob2fp

1.0.0 • Public • Published

npm mit license build status coverage status deps status

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 available options.criteria function
  • returns {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 MIT license

Copyright (c) 2014-2015 Charlike Mike Reagent, contributors.
Released under the MIT license.


Powered and automated by kdf, February 10, 2015

Package Sidebar

Install

npm i glob2fp

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • vanchoy
  • tunnckocore