Skip to content

Commit

Permalink
Expand directories in ignore option (sindresorhus#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdougherty committed Jan 27, 2018
1 parent 8b4ea64 commit 96761c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ const generateGlobTasks = (patterns, taskOpts) => {
nodir: true
}, taskOpts);

if (taskOpts.expandDirectories) {
taskOpts.ignore = dirGlob.sync(taskOpts.ignore);
}

patterns.forEach((pattern, i) => {
if (isNegative(pattern)) {
return;
Expand Down
11 changes: 11 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ test('expandDirectories option', t => {
}), ['tmp/a.tmp']);
});

test('expandDirectories and ignores option', t => {
t.deepEqual(m.sync('tmp', {
ignore: ['tmp']
}), []);

t.deepEqual(m.sync('tmp/**', {
expandDirectories: false,
ignore: ['tmp']
}), ['tmp/a.tmp', 'tmp/b.tmp', 'tmp/c.tmp', 'tmp/d.tmp', 'tmp/e.tmp']);
});

test('expandDirectories:true and nodir:true option', t => {
t.deepEqual(m.sync('tmp', {nodir: true}), ['tmp/a.tmp', 'tmp/b.tmp', 'tmp/c.tmp', 'tmp/d.tmp', 'tmp/e.tmp']);
t.deepEqual(m.sync('tmp', {nodir: false}), ['tmp', 'tmp/a.tmp', 'tmp/b.tmp', 'tmp/c.tmp', 'tmp/d.tmp', 'tmp/e.tmp']);
Expand Down

0 comments on commit 96761c7

Please sign in to comment.