Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use micromatch & glob-parent instead of minimatch & glob2base #56

Merged
merged 3 commits into from
Nov 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ You can pass any combination of globs. One caveat is that you can not only pass
- cwd
- Default is `process.cwd()`
- base
- Default is everything before a glob starts (see [glob2base](https://github.com/wearefractal/glob2base))
- Default is everything before a glob starts (see [glob-parent](https://github.com/es128/glob-parent))
- cwdbase
- Default is `false`
- When true it is the same as saying opt.base = opt.cwd
Expand Down
13 changes: 6 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ var Combine = require('ordered-read-streams');
var unique = require('unique-stream');

var glob = require('glob');
var Minimatch = require('minimatch').Minimatch;
var micromatch = require('micromatch');
var resolveGlob = require('to-absolute-glob');
var glob2base = require('glob2base');
var path = require('path');
var globParent = require('glob-parent');
var extend = require('extend');

var gs = {
Expand All @@ -24,7 +23,7 @@ var gs = {
var globber = new glob.Glob(ourGlob, ourOpt);

// Extract base path from glob
var basePath = opt.base || glob2base(globber);
var basePath = opt.base || globParent(ourGlob) + '/';

// Create stream and map events from globber to it
var stream = through2.obj(opt,
Expand Down Expand Up @@ -108,7 +107,7 @@ var gs = {
// Create Minimatch instances for negative glob patterns
if (globArray === negatives && typeof glob === 'string') {
var ourGlob = resolveGlob(glob, opt);
glob = new Minimatch(ourGlob, ourOpt);
glob = micromatch.matcher(ourGlob, ourOpt);
}

globArray.push({
Expand Down Expand Up @@ -149,8 +148,8 @@ var gs = {
};

function isMatch(file, matcher) {
if (matcher instanceof Minimatch) {
return matcher.match(file.path);
if (typeof matcher === 'function') {
return matcher(file.path);
}
if (matcher instanceof RegExp) {
return matcher.test(file.path);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"dependencies": {
"extend": "^3.0.0",
"glob": "^5.0.3",
"glob2base": "^0.0.12",
"minimatch": "^2.0.1",
"glob-parent": "^2.0.0",
"micromatch": "^2.3.0",
"ordered-read-streams": "^0.3.0",
"through2": "^0.6.0",
"to-absolute-glob": "^0.1.1",
Expand Down