From 40b9ffde5f97c6da56f5435a39f7532e66c30cdc Mon Sep 17 00:00:00 2001 From: ehmicky Date: Mon, 3 Aug 2020 18:48:27 +0200 Subject: [PATCH] Simplify detectors a little more --- src/detectors/utils/jsdetect.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/detectors/utils/jsdetect.js b/src/detectors/utils/jsdetect.js index 52f7987da9e..51a9477a943 100644 --- a/src/detectors/utils/jsdetect.js +++ b/src/detectors/utils/jsdetect.js @@ -74,18 +74,14 @@ function scanScripts({ preferredScriptsArr, preferredCommand }) { * */ // this is very simplistic logic, we can offer far more intelligent logic later // eg make a dependency tree of npm scripts and offer the parentest node first - const possibleArgsArrs = preferredScriptsArr - .filter(s => Object.keys(scripts).includes(s)) - .filter(s => !scripts[s].includes('netlify dev')) // prevent netlify dev calling netlify dev - .map(x => [x]) // make into arr of arrs - - Object.entries(scripts) - .filter(([k]) => !preferredScriptsArr.includes(k)) - .forEach(([k, v]) => { - if (v.includes(preferredCommand)) possibleArgsArrs.push([k]) - }) - - return possibleArgsArrs + return Object.entries(scripts) + .filter( + ([scriptName, scriptCommand]) => + (preferredScriptsArr.includes(scriptName) || scriptCommand.includes(preferredCommand)) && + // prevent netlify dev calling netlify dev + !scriptCommand.includes('netlify dev') + ) + .map(([scriptName]) => [scriptName]) } module.exports = {