-
Notifications
You must be signed in to change notification settings - Fork 204
Expand file tree
/
Copy pathvalidate.js
More file actions
39 lines (33 loc) · 1.15 KB
/
validate.js
File metadata and controls
39 lines (33 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const spawn = require('cross-spawn')
const {
parseEnv,
resolveBin,
ifScript,
getConcurrentlyArgs,
} = require('../utils')
// precommit runs linting and tests on the relevant files
// so those scripts don't need to be run if we're running
// this in the context of a precommit hook.
const precommit = parseEnv('SCRIPTS_PRECOMMIT', false)
const validateScripts = process.argv[2]
const useDefaultScripts = typeof validateScripts !== 'string'
const scripts = useDefaultScripts
? {
build: ifScript('build', 'npm run build --silent'),
format: precommit ? null : ifScript('format', 'npm run format -- --list-different'),
lint: precommit ? null : ifScript('lint', 'npm run lint --silent'),
test: precommit
? null
: ifScript('test', 'npm run test --silent -- --coverage'),
flow: ifScript('flow', 'npm run flow --silent'),
}
: validateScripts.split(',').reduce((scriptsToRun, name) => {
scriptsToRun[name] = `npm run ${name} --silent`
return scriptsToRun
}, {})
const result = spawn.sync(
resolveBin('concurrently'),
getConcurrentlyArgs(scripts),
{stdio: 'inherit'},
)
process.exit(result.status)