xglob
glob with mulptiple patterns
Last updated 4 years ago by zoubin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install xglob 
SYNC missed versions from official npm registry.

xglob

glob with mulptiple patterns.

Additionally, negation pattern can be functions or regular expressions. If truthy value returned, the negation pattern matches.

Example

⌘ tree fixtures/
fixtures/
├── a.css
├── a.js
├── d.js
├── dir
│   ├── b.css
│   ├── b.js
│   ├── c.js
│   ├── e
│   │   ├── e.css
│   │   └── e.js
│   └── f
│       ├── f.css
│       └── f.js
└── empty

glob(patterns, opts, cb)

glob(['**/', '!*/'], { cwd: fixtures }, function (err, files) {
  console.log(files.sort());
  // [ 'dir/e/', 'dir/f/'  ]
});

files = glob.sync(patterns, opts)

console.log(
  glob.sync(['**/', '!*/'], { cwd: fixtures }).sort()
);
// [ 'dir/e/', 'dir/f/'  ]

negation function

var path = require('util-path');
console.log(
  glob.sync(['**/*.js', '**/*.css', function (file) {
    var basename = path.replaceExtname(path.basename(file));
    var dir = path.basename(path.dirname(file));
    return basename !== dir;
  }], { cwd: fixtures }).sort()
);
// [ 'dir/e/e.css', 'dir/e/e.js', 'dir/f/f.css', 'dir/f/f.js'  ]

Usage

var glob = require('xglob');

glob(patterns, opts, cb)

patterns

Type: String, Array

Passed to glob for locating files.

files = glob.sync(patterns, opts)

glob.glob

glob

Current Tags

  • 1.0.0                                ...           latest (4 years ago)

4 Versions

  • 1.0.0                                ...           4 years ago
  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 4
This Week 4
This Month 6
Last Day 0
Last Week 0
Last Month 8
Dependencies (3)
Dev Dependencies (3)

Copyright 2014 - 2017 © taobao.org |