diff --git a/lib/utils.js b/lib/utils.js index 987b6c5adc..319f1b5e71 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -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