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

97 #124

Closed
wants to merge 3 commits into from
Closed

97 #124

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
15 changes: 15 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,27 @@ const checkCwdOption = options => {
}
};

// https://github.com/sindresorhus/globby/issues/97
const checkExtensionOptions = options => {
if (
options &&
(options.noext === true || options.extension === false) &&
options.expandDirectories.extensions &&
options.expandDirectories.extensions.length !== 0
) {
throw new Error(
'Using noext and expandDirectories.extensions together will fail due to upstream bugs. #97'
);
}
};

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

const generateGlobTasks = (patterns, taskOptions) => {
patterns = arrayUnion([].concat(patterns));
assertPatternsInput(patterns);
checkCwdOption(taskOptions);
checkExtensionOptions(taskOptions);

const globTasks = [];

Expand Down
24 changes: 24 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,30 @@ test.failing('`{extension: false}` and `expandDirectories.extensions` option', t
);
});

test('`{extension: false}` and `expandDirectories.extensions` option throws error', async t => {
await t.throwsAsync(globby(tmp, {
extension: false,
expandDirectories: {
extensions: ['md', 'tmp']
}
}),
'Using noext and expandDirectories.extensions together will fail due to upstream bugs. #97'
);
});

test('`{extension: false}` and `expandDirectories.extensions` option throws error - sync', t => {
t.throws(
() =>
globby.sync(tmp, {
extension: false,
expandDirectories: {
extensions: ['md', 'tmp']
}
}),
'Using noext and expandDirectories.extensions together will fail due to upstream bugs. #97'
);
});

test('throws when specifying a file as cwd - async', async t => {
const isFile = path.resolve('fixtures/gitignore/bar.js');

Expand Down