Skip to content

Commit

Permalink
Merge pull request #55 from jonschlinkert/master
Browse files Browse the repository at this point in the history
addresses absolute-glob issue 53
  • Loading branch information
phated committed Nov 5, 2015
2 parents e3d5548 + 51e9902 commit 4bf51e9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
17 changes: 2 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var unique = require('unique-stream');

var glob = require('glob');
var Minimatch = require('minimatch').Minimatch;
var resolveGlob = require('to-absolute-glob');
var glob2base = require('glob2base');
var path = require('path');
var extend = require('extend');
Expand Down Expand Up @@ -46,7 +47,7 @@ var gs = {
stream.write({
cwd: opt.cwd,
base: basePath,
path: path.resolve(opt.cwd, filename),
path: filename,
});
});

Expand Down Expand Up @@ -165,20 +166,6 @@ function isNegative(pattern) {
}
}

function resolveGlob(glob, opt) {
var mod = '';
if (glob[0] === '!') {
mod = glob[0];
glob = glob.slice(1);
}
if (opt.root && glob[0] === '/') {
glob = path.resolve(opt.root, '.' + glob);
} else {
glob = path.resolve(opt.cwd, glob);
}
return mod + glob;
}

function indexGreaterThan(index) {
return function(obj) {
return obj.index > index;
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
"dependencies": {
"extend": "^3.0.0",
"glob": "^5.0.3",
"glob2base": "^0.0.12",
"minimatch": "^2.0.1",
"ordered-read-streams": "^0.3.0",
"glob2base": "^0.0.12",
"unique-stream": "^2.0.2",
"through2": "^0.6.0"
"through2": "^0.6.0",
"to-absolute-glob": "^0.1.1",
"unique-stream": "^2.0.2"
},
"devDependencies": {
"coveralls": "^2.11.2",
Expand Down
18 changes: 18 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ describe('glob-stream', function() {
});
});

it('should return only folder name stream from a glob', function(done) {
var folderCount = 0;
var stream = gs.create('./fixtures/whatsgoingon/*/', { cwd: __dirname });
stream.on('error', function(err) {
throw err;
});
stream.on('data', function(file) {
should.exist(file);
should.exist(file.path);
String(join(file.path, '')).should.equal(join(__dirname, './fixtures/whatsgoingon/hey/'));
folderCount++;
});
stream.on('end', function() {
folderCount.should.equal(1);
done();
});
});

it('should return a file name stream from a glob', function(done) {
var stream = gs.create('./fixtures/*.coffee', { cwd: __dirname });
should.exist(stream);
Expand Down

0 comments on commit 4bf51e9

Please sign in to comment.