diff --git a/templates/app/package-scripts.js.ejs b/templates/app/package-scripts.js.ejs index 3bbb7a5..14c63ef 100644 --- a/templates/app/package-scripts.js.ejs +++ b/templates/app/package-scripts.js.ejs @@ -12,7 +12,7 @@ setColors(['dim']) const script = (script, description) => description ? {script, description} : {script} -const lint = { +const linters = { eslint: script('eslint .', 'lint js files'), <%_ if (semantic_release) { _%> commitlint: script('commitlint --from origin/master', 'ensure that commits are in valid conventional-changelog format'), @@ -23,42 +23,36 @@ const lint = { <%_ } _%> } -const linters = Object.keys(lint).map(l => `lint.${l}`) -lint.default = concurrent.nps(...linters) - -const test = { +const scripts = { + ...linters, + lint: concurrent(linters), <%_ if (mocha) { _%> - default: script(concurrent.nps(...linters, 'test.mocha'), 'lint and run all tests'), + test: script(concurrent.nps(...Object.keys(linters), 'mocha'), 'lint and run all tests'), mocha: script('mocha --forbid-only "test/**/*.test.ts"', 'run all mocha tests'), <%_ } else { _%> - default: lint.default + test: concurrent(linters), <%_ } _%> } -const scripts = { - lint, - test, -} - <%_ if (mocha) { _%> if (process.env.CI) { if (process.env.CIRCLECI) { - test.default.script = series(mkdirp('reports'), test.default.script) + scripts.mocha.script = series(mkdirp('reports'), scripts.mocha.script) // add mocha junit reporter - test.mocha.script = crossEnv(`MOCHA_FILE=reports/mocha.xml ${test.mocha.script} --reporter mocha-junit-reporter`) + scripts.mocha.script = crossEnv(`MOCHA_FILE=reports/mocha.xml ${scripts.mocha.script} --reporter mocha-junit-reporter`) // add eslint reporter - lint.eslint.script = `${lint.eslint.script} --format junit --output-file reports/eslint.xml` + scripts.eslint.script = `${scripts.eslint.script} --format junit --output-file reports/eslint.xml` <%_ if (ts) { _%> // add tslint reporter - lint.tslint.script = `${lint.tslint.script} --format junit > reports/tslint.xml` + scripts.tslint.script = `${scripts.tslint.script} --format junit > reports/tslint.xml` <%_ } _%> scripts.release = 'semantic-release -e @dxcli/dev-semantic-release' } // add code coverage reporting with nyc const nyc = 'nyc --nycrc-path node_modules/@dxcli/dev-nyc-config/.nycrc' const nycReport = `${nyc} report --reporter text-lcov > coverage.lcov` - test.mocha.script = series(`${nyc} ${test.mocha.script}`, nycReport) + scripts.mocha.script = series(`${nyc} ${scripts.mocha.script}`, nycReport) } -<%_ } _%> +<%_ } _%> module.exports = {scripts}