Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix using the gitignore and stats options together #121

Merged
merged 1 commit into from
May 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix { gitignore, stats } interaction
  • Loading branch information
jamiebuilds committed May 25, 2019
commit a45831da4bfda6e97bb4233a147273a44d4cadb1
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const checkCwdOption = options => {
}
};

const getPathString = p => p instanceof fs.Stats ? p.path : p;

const generateGlobTasks = (patterns, taskOptions) => {
patterns = arrayUnion([].concat(patterns));
assertPatternsInput(patterns);
Expand Down Expand Up @@ -110,7 +112,7 @@ const globby = (patterns, options) => {
return getTasks
.then(tasks => Promise.all(tasks.map(task => fastGlob(task.pattern, task.options))))
.then(paths => arrayUnion(...paths))
.then(paths => paths.filter(p => !filter(p)));
.then(paths => paths.filter(p => !filter(getPathString(p))));
});
};

Expand Down
6 changes: 6 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ test('respects gitignore option false - sync', t => {
t.true(actual.indexOf('node_modules') > -1);
});

test('gitignore option with stats option', async t => {
const res = await globby('*', {gitignore: true, stats: true});
const actual = res.map(s => s.path);
t.false(actual.indexOf('node_modules') > -1);
});

// https://github.com/sindresorhus/globby/issues/97
test.failing('`{extension: false}` and `expandDirectories.extensions` option', t => {
t.deepEqual(
Expand Down