diff --git a/index.js b/index.js index dae8c09..637cc5e 100644 --- a/index.js +++ b/index.js @@ -6,12 +6,11 @@ var unique = require('unique-stream'); var glob = require('glob'); var pumpify = require('pumpify'); -var resolveGlob = require('to-absolute-glob'); var isNegatedGlob = require('is-negated-glob'); var globParent = require('glob-parent'); -var path = require('path'); +var resolveGlob = require('to-absolute-glob'); var extend = require('extend'); -var sepRe = (process.platform === 'win32' ? /[\/\\]/ : /\/+/); +var removeTrailingSeparator = require('remove-trailing-separator'); function globStream(globs, opt) { if (!opt) { @@ -137,7 +136,7 @@ function createStream(ourGlob, negatives, opt) { stream.write({ cwd: opt.cwd, base: basePath, - path: path.normalize(filename), + path: removeTrailingSeparator(filename), }); }); return stream; @@ -165,19 +164,7 @@ function globIsSingular(glob) { } function getBasePath(ourGlob, opt) { - var basePath; - var parent = globParent(ourGlob); - - if (parent === '/' && opt && opt.root) { - basePath = path.normalize(opt.root); - } else { - basePath = resolveGlob(parent, opt); - } - - if (!sepRe.test(basePath.charAt(basePath.length - 1))) { - basePath += path.sep; - } - return basePath; + return globParent(resolveGlob(ourGlob, opt)); } module.exports = globStream; diff --git a/package.json b/package.json index 4655358..0678d90 100644 --- a/package.json +++ b/package.json @@ -22,13 +22,14 @@ }, "dependencies": { "extend": "^3.0.0", - "glob": "^7.0.6", + "glob": "^7.1.1", "glob-parent": "^3.0.0", "is-negated-glob": "^1.0.0", "ordered-read-streams": "^0.3.0", "pumpify": "^1.3.5", + "remove-trailing-separator": "^1.0.1", "through2": "^0.6.0", - "to-absolute-glob": "^0.1.1", + "to-absolute-glob": "^2.0.0", "unique-stream": "^2.0.2" }, "devDependencies": { diff --git a/test/main.js b/test/main.js index 958ca47..310fcf6 100644 --- a/test/main.js +++ b/test/main.js @@ -2,12 +2,16 @@ var globStream = require('../'); var through2 = require('through2'); var should = require('should'); var path = require('path'); -var join = path.join; -var sep = path.sep; + +function deWindows(p) { + return p.replace(/\\/g, '/'); +} + +var dir = deWindows(__dirname); describe('glob-stream', function() { it('should return a folder name stream from a glob', function(done) { - var stream = globStream('./fixtures/whatsgoingon', { cwd: __dirname }); + var stream = globStream('./fixtures/whatsgoingon', { cwd: dir }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -17,23 +21,23 @@ describe('glob-stream', function() { should.exist(file.path); should.exist(file.base); should.exist(file.cwd); - String(file.cwd).should.equal(__dirname); - String(file.base).should.equal(join(__dirname, 'fixtures' + sep)); - String(join(file.path,'')).should.equal(join(__dirname, './fixtures/whatsgoingon')); + String(file.cwd).should.equal(dir); + String(file.base).should.equal(dir + '/fixtures'); + String(file.path).should.equal(dir + '/fixtures/whatsgoingon'); done(); }); }); it('should return only folder name stream from a glob', function(done) { var folderCount = 0; - var stream = globStream('./fixtures/whatsgoingon/*/', { cwd: __dirname }); + var stream = globStream('./fixtures/whatsgoingon/*/', { cwd: dir }); 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/')); + String(file.path).should.equal(dir + '/fixtures/whatsgoingon/hey'); folderCount++; }); stream.on('end', function() { @@ -43,7 +47,7 @@ describe('glob-stream', function() { }); it('should return a file name stream from a glob', function(done) { - var stream = globStream('./fixtures/*.coffee', { cwd: __dirname }); + var stream = globStream('./fixtures/*.coffee', { cwd: dir }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -53,15 +57,15 @@ describe('glob-stream', function() { should.exist(file.path); should.exist(file.base); should.exist(file.cwd); - String(file.cwd).should.equal(__dirname); - String(file.base).should.equal(join(__dirname, 'fixtures' + sep)); - String(join(file.path,'')).should.equal(join(__dirname, './fixtures/test.coffee')); + String(file.cwd).should.equal(dir); + String(file.base).should.equal(dir + '/fixtures'); + String(file.path).should.equal(dir + '/fixtures/test.coffee'); done(); }); }); it('should handle ( ) in directory paths', function(done) { - var cwd = join(__dirname, './fixtures/has (parens)'); + var cwd = dir + '/fixtures/has (parens)'; var stream = globStream('*.dmc', { cwd: cwd }); should.exist(stream); stream.on('error', function(err) { @@ -73,14 +77,14 @@ describe('glob-stream', function() { should.exist(file.base); should.exist(file.cwd); String(file.cwd).should.equal(cwd); - String(file.base).should.equal(cwd + sep); - String(join(file.path,'')).should.equal(join(cwd, 'test.dmc')); + String(file.base).should.equal(cwd); + String(file.path).should.equal(cwd + '/test.dmc'); done(); }); }); it('should set the correct base when ( ) in glob', function(done) { - var stream = globStream('./fixtures/has (parens)/*.dmc', { cwd: __dirname }); + var stream = globStream('./fixtures/has (parens)/*.dmc', { cwd: dir }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -90,15 +94,15 @@ describe('glob-stream', function() { should.exist(file.path); should.exist(file.base); should.exist(file.cwd); - String(file.cwd).should.equal(__dirname); - String(file.base).should.equal(join(__dirname, 'fixtures/has (parens)/')); - String(join(file.path,'')).should.equal(join(__dirname, './fixtures/has (parens)/test.dmc')); + String(file.cwd).should.equal(dir); + String(file.base).should.equal(dir + '/fixtures/has (parens)'); + String(file.path).should.equal(dir + '/fixtures/has (parens)/test.dmc'); done(); }); }); it('should find files in paths that contain ( )', function(done) { - var stream = globStream('./fixtures/**/*.dmc', { cwd: __dirname }); + var stream = globStream('./fixtures/**/*.dmc', { cwd: dir }); var files = []; stream.on('error', done); stream.on('data', function(file) { @@ -109,17 +113,17 @@ describe('glob-stream', function() { stream.on('end', function() { files.length.should.equal(3); path.basename(files[0].path).should.equal('test.dmc'); - files[0].path.should.equal(join(__dirname, 'fixtures/has (parens)/test.dmc')); + files[0].path.should.equal(dir + '/fixtures/has (parens)/test.dmc'); path.basename(files[1].path).should.equal('run.dmc'); - files[1].path.should.equal(join(__dirname, 'fixtures/stuff/run.dmc')); + files[1].path.should.equal(dir + '/fixtures/stuff/run.dmc'); path.basename(files[2].path).should.equal('test.dmc'); - files[2].path.should.equal(join(__dirname, 'fixtures/stuff/test.dmc')); + files[2].path.should.equal(dir + '/fixtures/stuff/test.dmc'); done(); }); }); it('should return a file name stream from a glob and respect state', function(done) { - var stream = globStream('./fixtures/stuff/*.dmc', { cwd: __dirname }); + var stream = globStream('./fixtures/stuff/*.dmc', { cwd: dir }); var wrapper = stream.pipe(through2.obj(function(data, enc, cb) { this.pause(); setTimeout(function() { @@ -145,7 +149,7 @@ describe('glob-stream', function() { }); it('should return a correctly ordered file name stream for two globs and specified base', function(done) { - var baseDir = join(__dirname, './fixtures'); + var baseDir = dir + '/fixtures'; var globArray = [ './whatsgoingon/hey/isaidhey/whatsgoingon/test.txt', @@ -166,7 +170,7 @@ describe('glob-stream', function() { }); it('should return a correctly ordered file name stream for two globs and cwdbase', function(done) { - var baseDir = join(__dirname, './fixtures'); + var baseDir = dir + '/fixtures'; var globArray = [ './whatsgoingon/hey/isaidhey/whatsgoingon/test.txt', @@ -187,7 +191,7 @@ describe('glob-stream', function() { }); it('should return a file name stream that does not duplicate', function(done) { - var stream = globStream(['./fixtures/test.coffee', './fixtures/test.coffee'], { cwd: __dirname }); + var stream = globStream(['./fixtures/test.coffee', './fixtures/test.coffee'], { cwd: dir }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -197,16 +201,16 @@ describe('glob-stream', function() { should.exist(file.path); should.exist(file.base); should.exist(file.cwd); - String(file.cwd).should.equal(__dirname); - String(file.base).should.equal(join(__dirname, 'fixtures' + sep)); - String(file.path).should.equal(join(__dirname, './fixtures/test.coffee')); + String(file.cwd).should.equal(dir); + String(file.base).should.equal(dir + '/fixtures'); + String(file.path).should.equal(dir + '/fixtures/test.coffee'); done(); }); }); it('should return a file name stream that does not duplicate when piped twice', function(done) { - var stream = globStream('./fixtures/test.coffee', { cwd: __dirname }); - var stream2 = globStream('./fixtures/test.coffee', { cwd: __dirname }); + var stream = globStream('./fixtures/test.coffee', { cwd: dir }); + var stream2 = globStream('./fixtures/test.coffee', { cwd: dir }); stream2.pipe(stream); should.exist(stream); @@ -218,16 +222,16 @@ describe('glob-stream', function() { should.exist(file.path); should.exist(file.base); should.exist(file.cwd); - String(file.cwd).should.equal(__dirname); - String(file.base).should.equal(join(__dirname, 'fixtures' + sep)); - String(file.path).should.equal(join(__dirname, './fixtures/test.coffee')); + String(file.cwd).should.equal(dir); + String(file.base).should.equal(dir + '/fixtures'); + String(file.path).should.equal(dir + '/fixtures/test.coffee'); done(); }); }); it('should return a file name stream from a direct path', function(done) { - var stream = globStream('./fixtures/test.coffee', { cwd: __dirname }); + var stream = globStream('./fixtures/test.coffee', { cwd: dir }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -237,15 +241,15 @@ describe('glob-stream', function() { should.exist(file.path); should.exist(file.base); should.exist(file.cwd); - String(file.cwd).should.equal(__dirname); - String(file.base).should.equal(join(__dirname, 'fixtures' + sep)); - String(file.path).should.equal(join(__dirname, './fixtures/test.coffee')); + String(file.cwd).should.equal(dir); + String(file.base).should.equal(dir + '/fixtures'); + String(file.path).should.equal(dir + '/fixtures/test.coffee'); done(); }); }); it('should not return a file name stream with dotfiles without dot option', function(done) { - var stream = globStream('./fixtures/*swag', { cwd: __dirname }); + var stream = globStream('./fixtures/*swag', { cwd: dir }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -257,7 +261,7 @@ describe('glob-stream', function() { }); it('should return a file name stream with dotfiles with dot option', function(done) { - var stream = globStream('./fixtures/*swag', { cwd: __dirname, dot: true }); + var stream = globStream('./fixtures/*swag', { cwd: dir, dot: true }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -267,15 +271,15 @@ describe('glob-stream', function() { should.exist(file.path); should.exist(file.base); should.exist(file.cwd); - String(file.cwd).should.equal(__dirname); - String(file.base).should.equal(join(__dirname, 'fixtures' + sep)); - String(file.path).should.equal(join(__dirname, './fixtures/.swag')); + String(file.cwd).should.equal(dir); + String(file.base).should.equal(dir + '/fixtures'); + String(file.path).should.equal(dir + '/fixtures/.swag'); done(); }); }); it('should return a file name stream with dotfiles negated', function(done) { - var stream = globStream(['./fixtures/*swag', '!./fixtures/**'], { cwd: __dirname, dot: true }); + var stream = globStream(['./fixtures/*swag', '!./fixtures/**'], { cwd: dir, dot: true }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -287,7 +291,7 @@ describe('glob-stream', function() { }); it('should return a file name stream from a direct path and pause/buffer items', function(done) { - var stream = globStream('./fixtures/test.coffee', { cwd: __dirname }); + var stream = globStream('./fixtures/test.coffee', { cwd: dir }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -297,9 +301,9 @@ describe('glob-stream', function() { should.exist(file.path); should.exist(file.base); should.exist(file.cwd); - String(file.cwd).should.equal(__dirname); - String(file.base).should.equal(join(__dirname, 'fixtures' + sep)); - String(file.path).should.equal(join(__dirname, './fixtures/test.coffee')); + String(file.cwd).should.equal(dir); + String(file.base).should.equal(dir + '/fixtures'); + String(file.path).should.equal(dir + '/fixtures/test.coffee'); done(); }); stream.pause(); @@ -309,7 +313,7 @@ describe('glob-stream', function() { }); it('should not fuck up direct paths with no cwd', function(done) { - var stream = globStream(join(__dirname, './fixtures/test.coffee')); + var stream = globStream(dir + '/fixtures/test.coffee'); should.exist(stream); stream.on('error', function(err) { throw err; @@ -320,20 +324,20 @@ describe('glob-stream', function() { should.exist(file.base); should.exist(file.cwd); String(file.cwd).should.equal(process.cwd()); - String(file.base).should.equal(join(__dirname, './fixtures/')); - String(join(file.path,'')).should.equal(join(__dirname, './fixtures/test.coffee')); + String(file.base).should.equal(dir + '/fixtures'); + String(file.path).should.equal(dir + '/fixtures/test.coffee'); done(); }); }); it('should return a correctly ordered file name stream for three globs with globstars', function(done) { var globArray = [ - join(__dirname, './fixtures/**/test.txt'), - join(__dirname, './fixtures/**/test.coffee'), - join(__dirname, './fixtures/**/test.js'), - join(__dirname, './fixtures/**/test.dmc'), + dir + '/fixtures/**/test.txt', + dir + '/fixtures/**/test.coffee', + dir + '/fixtures/**/test.js', + dir + '/fixtures/**/test.dmc', ]; - var stream = globStream(globArray, { cwd: __dirname }); + var stream = globStream(globArray, { cwd: dir }); var files = []; stream.on('error', done); @@ -355,11 +359,11 @@ describe('glob-stream', function() { it('should return a correctly ordered file name stream for two globs', function(done) { var globArray = [ - join(__dirname, './fixtures/whatsgoingon/hey/isaidhey/whatsgoingon/test.txt'), - join(__dirname, './fixtures/test.coffee'), - join(__dirname, './fixtures/whatsgoingon/test.js'), + dir + '/fixtures/whatsgoingon/hey/isaidhey/whatsgoingon/test.txt', + dir + '/fixtures/test.coffee', + dir + '/fixtures/whatsgoingon/test.js', ]; - var stream = globStream(globArray, { cwd: __dirname }); + var stream = globStream(globArray, { cwd: dir }); var files = []; stream.on('error', done); @@ -378,7 +382,7 @@ describe('glob-stream', function() { }); it('should return a correctly ordered file name stream for two globs and custom base', function(done) { - var baseDir = join(__dirname, './fixtures'); + var baseDir = dir + '/fixtures'; var globArray = [ './whatsgoingon/hey/isaidhey/whatsgoingon/test.txt', @@ -399,10 +403,10 @@ describe('glob-stream', function() { }); it('should return a input stream for multiple globs, with negation (globbing)', function(done) { - var expectedPath = join(__dirname, './fixtures/stuff/run.dmc'); + var expectedPath = dir + '/fixtures/stuff/run.dmc'; var globArray = [ - join(__dirname, './fixtures/stuff/*.dmc'), - '!' + join(__dirname, './fixtures/stuff/test.dmc'), + dir + '/fixtures/stuff/*.dmc', + '!' + dir + '/fixtures/stuff/test.dmc', ]; var stream = globStream(globArray); @@ -421,10 +425,10 @@ describe('glob-stream', function() { }); it('should return a input stream for multiple globs, with negation (direct)', function(done) { - var expectedPath = join(__dirname, './fixtures/stuff/run.dmc'); + var expectedPath = dir + '/fixtures/stuff/run.dmc'; var globArray = [ - join(__dirname, './fixtures/stuff/run.dmc'), - '!' + join(__dirname, './fixtures/stuff/test.dmc'), + dir + '/fixtures/stuff/run.dmc', + '!' + dir + '/fixtures/stuff/test.dmc', ]; var stream = globStream(globArray); @@ -443,8 +447,8 @@ describe('glob-stream', function() { }); it('should return a input stream that can be piped to other input streams and remove duplicates', function(done) { - var stream = globStream(join(__dirname, './fixtures/stuff/*.dmc')); - var stream2 = globStream(join(__dirname, './fixtures/stuff/*.dmc')); + var stream = globStream(dir + '/fixtures/stuff/*.dmc'); + var stream2 = globStream(dir + '/fixtures/stuff/*.dmc'); stream2.pipe(stream); @@ -462,7 +466,7 @@ describe('glob-stream', function() { }); it('should return a file name stream with negation from a glob', function(done) { - var stream = globStream(['./fixtures/**/*.js', '!./**/test.js'], { cwd: __dirname }); + var stream = globStream(['./fixtures/**/*.js', '!./**/test.js'], { cwd: dir }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -476,7 +480,7 @@ describe('glob-stream', function() { }); it('should return a file name stream from two globs and a negative', function(done) { - var stream = globStream(['./fixtures/*.coffee', './fixtures/whatsgoingon/*.coffee'], { cwd: __dirname }); + var stream = globStream(['./fixtures/*.coffee', './fixtures/whatsgoingon/*.coffee'], { cwd: dir }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -486,15 +490,15 @@ describe('glob-stream', function() { should.exist(file.path); should.exist(file.base); should.exist(file.cwd); - String(file.cwd).should.equal(__dirname); - String(file.base).should.equal(join(__dirname, 'fixtures' + sep)); - String(join(file.path,'')).should.equal(join(__dirname, './fixtures/test.coffee')); + String(file.cwd).should.equal(dir); + String(file.base).should.equal(dir + '/fixtures'); + String(file.path).should.equal(dir + '/fixtures/test.coffee'); done(); }); }); it('should respect the globs array order', function(done) { - var stream = globStream(['./fixtures/stuff/*', '!./fixtures/stuff/*.dmc', './fixtures/stuff/run.dmc'], { cwd: __dirname }); + var stream = globStream(['./fixtures/stuff/*', '!./fixtures/stuff/*.dmc', './fixtures/stuff/run.dmc'], { cwd: dir }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -504,15 +508,15 @@ describe('glob-stream', function() { should.exist(file.path); should.exist(file.base); should.exist(file.cwd); - String(file.cwd).should.equal(__dirname); - String(file.base).should.equal(join(__dirname, 'fixtures', 'stuff' + sep)); - String(join(file.path,'')).should.equal(join(__dirname, './fixtures/stuff/run.dmc')); + String(file.cwd).should.equal(dir); + String(file.base).should.equal(dir + '/fixtures/stuff'); + String(file.path).should.equal(dir + '/fixtures/stuff/run.dmc'); done(); }); }); it('should ignore leading negative globs', function(done) { - var stream = globStream(['!./fixtures/stuff/*.dmc', './fixtures/stuff/run.dmc'], { cwd: __dirname }); + var stream = globStream(['!./fixtures/stuff/*.dmc', './fixtures/stuff/run.dmc'], { cwd: dir }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -522,21 +526,21 @@ describe('glob-stream', function() { should.exist(file.path); should.exist(file.base); should.exist(file.cwd); - String(file.cwd).should.equal(__dirname); - String(file.base).should.equal(join(__dirname, 'fixtures', 'stuff' + sep)); - String(join(file.path,'')).should.equal(join(__dirname, './fixtures/stuff/run.dmc')); + String(file.cwd).should.equal(dir); + String(file.base).should.equal(dir + '/fixtures/stuff'); + String(file.path).should.equal(dir + '/fixtures/stuff/run.dmc'); done(); }); }); it('should throw on invalid glob argument', function() { - globStream.bind(globStream, 42, { cwd: __dirname }).should.throw(/Invalid glob .* 0/); - globStream.bind(globStream, ['.', 42], { cwd: __dirname }).should.throw(/Invalid glob .* 1/); + globStream.bind(globStream, 42, { cwd: dir }).should.throw(/Invalid glob .* 0/); + globStream.bind(globStream, ['.', 42], { cwd: dir }).should.throw(/Invalid glob .* 1/); }); it('should throw on missing positive glob', function() { - globStream.bind(globStream, '!c', { cwd: __dirname }).should.throw(/Missing positive glob/); - globStream.bind(globStream, ['!a', '!b'], { cwd: __dirname }).should.throw(/Missing positive glob/); + globStream.bind(globStream, '!c', { cwd: dir }).should.throw(/Missing positive glob/); + globStream.bind(globStream, ['!a', '!b'], { cwd: dir }).should.throw(/Missing positive glob/); }); it('should emit error on singular glob when file not found', function(done) { @@ -549,7 +553,7 @@ describe('glob-stream', function() { }); it('should emit error when a glob in multiple globs not found', function(done) { - var stream = globStream(['notfound', './fixtures/whatsgoingon'], { cwd: __dirname }); + var stream = globStream(['notfound', './fixtures/whatsgoingon'], { cwd: dir }); should.exist(stream); stream.on('error', function(err) { err.should.match(/File not found with singular glob/); @@ -558,7 +562,7 @@ describe('glob-stream', function() { }); it('should resolve relative paths when root option is given', function(done) { - var stream = globStream('./fixtures/test.coffee', { cwd: __dirname, root: __dirname + '/fixtures' }); + var stream = globStream('./fixtures/test.coffee', { cwd: dir, root: dir + '/fixtures' }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -568,15 +572,15 @@ describe('glob-stream', function() { should.exist(file.path); should.exist(file.base); should.exist(file.cwd); - String(file.cwd).should.equal(__dirname); - String(file.base).should.equal(join(__dirname, 'fixtures' + sep)); - String(join(file.path,'')).should.equal(join(__dirname, './fixtures/test.coffee')); + String(file.cwd).should.equal(dir); + String(file.base).should.equal(dir + '/fixtures'); + String(file.path).should.equal(dir + '/fixtures/test.coffee'); done(); }); }); it('should resolve absolute paths when root option is given', function(done) { - var stream = globStream('/test.coffee', { cwd: __dirname, root: __dirname + '/fixtures' }); + var stream = globStream('/test.coffee', { cwd: dir, root: dir + '/fixtures' }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -586,9 +590,9 @@ describe('glob-stream', function() { should.exist(file.path); should.exist(file.base); should.exist(file.cwd); - String(file.cwd).should.equal(__dirname); - String(file.base).should.equal(join(__dirname, 'fixtures' + sep)); - String(join(file.path,'')).should.equal(join(__dirname, './fixtures/test.coffee')); + String(file.cwd).should.equal(dir); + String(file.base).should.equal(dir + '/fixtures'); + String(file.path).should.equal(dir + '/fixtures/test.coffee'); done(); }); }); @@ -616,7 +620,7 @@ describe('glob-stream', function() { }); it('should pass options to through2',function(done) { - var stream = globStream(['./fixtures/stuff/run.dmc'], { cwd: __dirname, objectMode: false }); + var stream = globStream(['./fixtures/stuff/run.dmc'], { cwd: dir, objectMode: false }); should.exist(stream); stream.on('error', function(err) { err.should.match(/Invalid non-string\/buffer chunk/); @@ -639,7 +643,7 @@ describe('options', function() { var opts = {}; - var stream = globStream(join(__dirname, './fixtures/stuff/run.dmc'), opts); + var stream = globStream(dir + '/fixtures/stuff/run.dmc', opts); Object.keys(opts).length.should.equal(0); opts.should.not.eql(defaultedOpts); stream.on('data', function() {}); @@ -649,9 +653,9 @@ describe('options', function() { describe('ignore', function() { it('accepts a string (in addition to array)', function(done) { - var expectedPath = join(__dirname, './fixtures/stuff/run.dmc'); - var glob = join(__dirname, './fixtures/stuff/*.dmc'); - var stream = globStream(glob, { cwd: __dirname, ignore: './fixtures/stuff/test.dmc' }); + var expectedPath = dir + '/fixtures/stuff/run.dmc'; + var glob = dir + '/fixtures/stuff/*.dmc'; + var stream = globStream(glob, { cwd: dir, ignore: './fixtures/stuff/test.dmc' }); var files = []; stream.on('error', done); @@ -668,9 +672,9 @@ describe('options', function() { }); it('should support the ignore option instead of negation', function(done) { - var expectedPath = join(__dirname, './fixtures/stuff/run.dmc'); - var glob = join(__dirname, './fixtures/stuff/*.dmc'); - var stream = globStream(glob, { cwd: __dirname, ignore: ['./fixtures/stuff/test.dmc'] }); + var expectedPath = dir + '/fixtures/stuff/run.dmc'; + var glob = dir + '/fixtures/stuff/*.dmc'; + var stream = globStream(glob, { cwd: dir, ignore: ['./fixtures/stuff/test.dmc'] }); var files = []; stream.on('error', done); @@ -687,7 +691,7 @@ describe('options', function() { }); it('should support the ignore option with dot option', function(done) { - var stream = globStream('./fixtures/*swag', { cwd: __dirname, dot: true, ignore: ['./fixtures/**'] }); + var stream = globStream('./fixtures/*swag', { cwd: dir, dot: true, ignore: ['./fixtures/**'] }); should.exist(stream); stream.on('error', function(err) { throw err; @@ -703,7 +707,7 @@ describe('options', function() { './fixtures/stuff/*.dmc', '!./fixtures/stuff/test.dmc', ]; - var stream = globStream(globArray, { cwd: __dirname, ignore: ['./fixtures/stuff/run.dmc'] }); + var stream = globStream(globArray, { cwd: dir, ignore: ['./fixtures/stuff/run.dmc'] }); should.exist(stream); stream.on('error', function(err) { throw err;