Skip to content

Commit

Permalink
utils.js: fix lookupFiles()
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Apr 26, 2019
1 parent 847a331 commit 03da22c
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions lib/utils.js
Expand Up @@ -576,24 +576,22 @@ exports.lookupFiles = function lookupFiles(filepath, extensions, recursive) {

if (!fs.existsSync(filepath)) {
// check all extensions
if (
!extensions.some(function(ext) {
if (fs.existsSync(filepath + '.' + ext)) {
filepath += '.' + ext;
return true;
}
})
) {
extensions.forEach(function(ext) {
if (fs.existsSync(filepath + '.' + ext)) {
files.push(filepath + '.' + ext);
}
});
if (!files.length) {
// Handle glob
files = glob.sync(filepath);
if (!files.length) {
throw createNoFilesMatchPatternError(
'Cannot find any files matching pattern ' + exports.dQuote(filepath),
filepath
);
}
return files;
}
if (!files.length) {
throw createNoFilesMatchPatternError(
'Cannot find any files matching pattern ' + exports.dQuote(filepath),
filepath
);
}
return files;
}

// Handle file
Expand Down

0 comments on commit 03da22c

Please sign in to comment.