Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Commit

Permalink
fix: fixed issues with package-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 27, 2018
1 parent f79cdba commit 571facb
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions templates/app/package-scripts.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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}

0 comments on commit 571facb

Please sign in to comment.