https://github.com/zoubin/xglob
glob with mulptiple patterns.
https://github.com/zoubin/xglob
Last synced: 10 days ago
JSON representation
glob with mulptiple patterns.
- Host: GitHub
- URL: https://github.com/zoubin/xglob
- Owner: zoubin
- Created: 2015-05-26T03:49:42.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-09-15T12:03:49.000Z (almost 11 years ago)
- Last Synced: 2025-02-08T23:35:11.704Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 152 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
Awesome Lists containing this project
README
# xglob
[glob](https://www.npmjs.com/package/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)
```javascript
glob(['**/', '!*/'], { cwd: fixtures }, function (err, files) {
console.log(files.sort());
// [ 'dir/e/', 'dir/f/' ]
});
```
### files = glob.sync(patterns, opts)
```javascript
console.log(
glob.sync(['**/', '!*/'], { cwd: fixtures }).sort()
);
// [ 'dir/e/', 'dir/f/' ]
```
### negation function
```javascript
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
```javascript
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](https://www.npmjs.com/package/glob)