Skip to content

Commit

Permalink
refactor: Cleanup code (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey authored May 25, 2020
1 parent 14b6682 commit 9f5e582
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
10 changes: 2 additions & 8 deletions src/run-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,8 @@ function getEnv() {
function spawnScript() {
// get all the arguments of the script and find the position of our script commands
const args = process.argv.slice(2)
const scriptIndex = args.findIndex(
x =>
x === 'format' ||
x === 'lint' ||
x === 'pre-commit' ||
x === 'test' ||
x === 'validate' ||
x === 'build',
const scriptIndex = args.findIndex(x =>
['build', 'format', 'lint', 'pre-commit', 'test', 'validate'].includes(x),
)

// Extract the node arguments so we can pass them to node later on
Expand Down
11 changes: 7 additions & 4 deletions src/scripts/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ const scripts = useDefaultScripts
: ifScript('test', 'npm run test --silent -- --coverage'),
typecheck: ifScript('typecheck', 'npm run typecheck --silent'),
}
: validateScripts.split(',').reduce((scriptsToRun, name) => {
scriptsToRun[name] = `npm run ${name} --silent`
return scriptsToRun
}, {})
: validateScripts.split(',').reduce(
(scriptsToRun, name) => ({
...scriptsToRun,
[name]: `npm run ${name} --silent`,
}),
{},
)

const scriptCount = Object.values(scripts).filter(Boolean).length

Expand Down

0 comments on commit 9f5e582

Please sign in to comment.