Skip to content

Commit

Permalink
Merge pull request #56 from es128/swap-deps
Browse files Browse the repository at this point in the history
Use micromatch & glob-parent instead of minimatch & glob2base
  • Loading branch information
phated committed Nov 17, 2015
2 parents 9aa7583 + ced76e8 commit b1a8de6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
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

0 comments on commit b1a8de6

Please sign in to comment.