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

Simplify detectors a little more #1069

Merged
merged 1 commit into from
Aug 3, 2020
Merged
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
20 changes: 8 additions & 12 deletions src/detectors/utils/jsdetect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down