42 lines
996 B
JavaScript
Executable File
42 lines
996 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
const { execFileSync, spawnSync } = require('child_process')
|
|
|
|
const run = (command, args) => {
|
|
const { status } = spawnSync(command, args, { stdio: 'inherit' })
|
|
if (status !== 0) {
|
|
process.exit(status)
|
|
}
|
|
}
|
|
|
|
const getFiles = () =>
|
|
execFileSync(
|
|
'git',
|
|
[
|
|
'diff-index',
|
|
'--diff-filter=AM',
|
|
'--ignore-submodules',
|
|
'--name-only',
|
|
'master',
|
|
],
|
|
{ encoding: 'utf8' }
|
|
)
|
|
.split('\n')
|
|
.filter(_ => _ !== '')
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Travis vars : https://docs.travis-ci.com/user/environment-variables#default-environment-variables.
|
|
if (process.env.TRAVIS_PULL_REQUEST !== 'false') {
|
|
const files = getFiles().filter(_ => _.endsWith('.js'))
|
|
if (files.length !== 0) {
|
|
run(
|
|
'./node_modules/.bin/jest',
|
|
['--findRelatedTests', '--passWithNoTests'].concat(files)
|
|
)
|
|
}
|
|
} else {
|
|
run('yarn', ['test'])
|
|
run('yarn', ['test-integration'])
|
|
}
|