-
-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: Added ignore option (fixes #115)
- Loading branch information
1 parent
941d53c
commit 31797f5
Showing
9 changed files
with
206 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
require('./global-leakage.js') | ||
// Ignore option test | ||
// Show that glob ignores results matching pattern on ignore option | ||
|
||
var glob = require('../glob.js') | ||
var test = require('tap').test | ||
|
||
test('get all', function(t) { | ||
var results = glob('*', {sync: true, cwd: 'a'}) | ||
t.same(results, ['abcdef', 'abcfed', 'b', 'bc', 'c', 'cb', 'symlink']) | ||
t.end() | ||
}); | ||
|
||
test('ignore b', function(t) { | ||
var results = glob('*', {sync: true, cwd: 'a', ignore: 'b'}) | ||
t.same(results, ['abcdef', 'abcfed', 'bc', 'c', 'cb', 'symlink']) | ||
t.end() | ||
}); | ||
|
||
test('ignore all with first letter as b', function(t) { | ||
var results = glob('*', {sync: true, cwd: 'a', ignore: 'b*'}); | ||
t.same(results, ['abcdef', 'abcfed', 'c', 'cb', 'symlink']) | ||
t.end() | ||
}); | ||
|
||
test('ignore b/c/d in b/c', function(t) { | ||
var results = glob('b/**', {sync: true, cwd: 'a', ignore: 'b/c/d'}); | ||
t.same(results, ['b', 'b/c']) | ||
t.end() | ||
}); | ||
|
||
// matches based on pattern specified | ||
test('ignores d in b/c only if pattern starts with b/c', function(t) { | ||
var results = glob('b/**', {sync: true, cwd: 'a', ignore: 'd'}); | ||
t.same(results, ['b', 'b/c', 'b/c/d']) | ||
t.end() | ||
}); | ||
|
||
test('ignore b/c and it\'s contents using globstar', function(t) { | ||
var results = glob('b/**', {sync: true, cwd: 'a', ignore: 'b/c/**'}) | ||
t.same(results, ['b']) | ||
t.end() | ||
}); | ||
|
||
test('ignore, get all d but that in b', function(t) { | ||
var results = glob('**/d', {sync: true, cwd: 'a', ignore: 'b/c/d'}) | ||
t.same(results, ['c/d']) | ||
t.end() | ||
}); | ||
|
||
test('ignore, get all a/**/[gh] except a/abcfed/g/h', function(t) { | ||
var results = glob('a/**/[gh]', {sync: true, ignore: ['a/abcfed/g/h']}) | ||
t.same(results, ['a/abcdef/g', 'a/abcdef/g/h', 'a/abcfed/g']) | ||
t.end() | ||
}); | ||
|
||
test('ignore, using multiple ignores', function(t) { | ||
var results = glob('*', {sync: true, cwd: 'a', ignore: ['c', 'bc', 'symlink', 'abcdef']}) | ||
t.same(results, ['abcfed', 'b', 'cb']) | ||
t.end() | ||
}); | ||
|
||
test('ignore, using multiple ignores and globstar', function(t) { | ||
var results = glob('a/**', {sync: true, ignore: ['a/c/**', 'a/bc/**', 'a/symlink/**', 'a/abcdef/**']}) | ||
t.same(results, ['a', 'a/abcfed', 'a/abcfed/g', 'a/abcfed/g/h', 'a/b', 'a/b/c', 'a/b/c/d', 'a/cb', 'a/cb/e', 'a/cb/e/f']) | ||
t.end() | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
require('./global-leakage.js') | ||
// Ignore option test | ||
// Show that glob ignores results matching pattern on ignore option | ||
|
||
var glob = require('../glob.js') | ||
var test = require('tap').test | ||
|
||
test('get all', function(t) { | ||
var results = glob('*', {cwd: 'a'}, function (er, results) { | ||
if (er) | ||
throw er | ||
t.same(results, ['abcdef', 'abcfed', 'b', 'bc', 'c', 'cb', 'symlink']) | ||
t.end() | ||
}) | ||
}); | ||
|
||
test('ignore b', function(t) { | ||
var results = glob('*', {cwd: 'a', ignore: 'b'}, function (er, results) { | ||
if (er) | ||
throw er | ||
t.same(results, ['abcdef', 'abcfed', 'bc', 'c', 'cb', 'symlink']) | ||
t.end() | ||
}) | ||
}); | ||
|
||
test('ignore all with first letter as b', function(t) { | ||
var results = glob('*', {cwd: 'a', ignore: 'b*'}, function (er, results) { | ||
if (er) | ||
throw er | ||
t.same(results, ['abcdef', 'abcfed', 'c', 'cb', 'symlink']) | ||
t.end() | ||
}); | ||
}); | ||
|
||
test('ignore b/c/d in b/c', function(t) { | ||
var results = glob('b/**', {cwd: 'a', ignore: 'b/c/d'}, function (er, results) { | ||
if (er) | ||
throw er | ||
t.same(results, ['b', 'b/c']) | ||
t.end() | ||
}); | ||
}); | ||
|
||
// matches based on pattern specified | ||
test('ignores d in b/c only if pattern starts with b/c', function(t) { | ||
var results = glob('b/**', {cwd: 'a', ignore: 'd'}, function (er, results) { | ||
if (er) | ||
throw er | ||
t.same(results, ['b', 'b/c', 'b/c/d']) | ||
t.end() | ||
}); | ||
}); | ||
|
||
test('ignore b/c and it\'s contents using globstar', function(t) { | ||
var results = glob('b/**', {cwd: 'a', ignore: 'b/c/**'}, function (er, results) { | ||
if (er) | ||
throw er | ||
t.same(results, ['b']) | ||
t.end() | ||
}) | ||
}); | ||
|
||
test('ignore, get all d but that in b', function(t) { | ||
var results = glob('**/d', {cwd: 'a', ignore: 'b/c/d'}, function (er, results) { | ||
if (er) | ||
throw er | ||
t.same(results, ['c/d']) | ||
t.end() | ||
}) | ||
}); | ||
|
||
test('ignore, get all a/**/[gh] except a/abcfed/g/h', function(t) { | ||
var results = glob('a/**/[gh]', {ignore: ['a/abcfed/g/h']}, function (er, results) { | ||
if (er) | ||
throw er | ||
t.same(results, ['a/abcdef/g', 'a/abcdef/g/h', 'a/abcfed/g']) | ||
t.end() | ||
}) | ||
}); | ||
|
||
test('ignore, using multiple ignores', function(t) { | ||
var results = glob('*', {cwd: 'a', ignore: ['c', 'bc', 'symlink', 'abcdef']}, function (er, results) { | ||
if (er) | ||
throw er | ||
t.same(results, ['abcfed', 'b', 'cb']) | ||
t.end() | ||
}) | ||
}); | ||
|
||
test('ignore, using multiple ignores and globstar', function(t) { | ||
var results = glob('a/**', {ignore: ['a/c/**', 'a/bc/**', 'a/symlink/**', 'a/abcdef/**']}, function (er, results) { | ||
if (er) | ||
throw er | ||
t.same(results, ['a', 'a/abcfed', 'a/abcfed/g', 'a/abcfed/g/h', 'a/b', 'a/b/c', 'a/b/c/d', 'a/cb', 'a/cb/e', 'a/cb/e/f']) | ||
t.end() | ||
}) | ||
}); |