/* eslint-disable unicorn/filename-case */ const { setColors, concurrent, <%_ if (mocha) { _%> crossEnv, mkdirp, series, <%_ } else if (ts) { _%> series, <%_ } _%> } = require('nps-utils') setColors(['dim']) const script = (script, description) => description ? {script, description} : {script} 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'), <%_ } _%> <%_ if (ts) { _%> tsc: script('tsc -p <%- mocha ? 'test' : '.' %> --noEmit', 'syntax check with tsc'), tslint: script('tslint -p <%- mocha ? 'test' : '.' %>', 'lint ts files'), <%_ } _%> } <%_ if (mocha) { _%> let mocha = 'mocha --forbid-only "test/**/*.test.<%- _ext %>"' if (process.env.CI) { if (process.env.CIRCLECI) { // add mocha junit reporter mocha = crossEnv(`MOCHA_FILE=reports/mocha.xml ${mocha} --reporter mocha-junit-reporter`) // add eslint reporter linters.eslint.script = `${linters.eslint.script} --format junit --output-file reports/eslint.xml` <%_ if (ts) { _%> // add tslint reporter linters.tslint.script = `${linters.tslint.script} --format junit > reports/tslint.xml` <%_ } _%> } // add code coverage reporting with nyc const nyc = 'nyc --nycrc-path node_modules/@anycli/nyc-config/.nycrc' const nycReport = `${nyc} report --reporter text-lcov > coverage.lcov` mocha = series(`${nyc} ${mocha}`, nycReport) } let test = concurrent({ ...linters, test: series(<%- ts ? "'nps build', " : ''%>mocha), }) if (process.env.CI) test = series(mkdirp('reports'), test) <%_ } else if (ts) { _%> let test = concurrent({...linters, build: 'nps build'}) <%_ } else { _%> let test = concurrent(linters) <%_ } _%> module.exports = { scripts: { ...linters, <%_ if (ts) { _%> build: series('rm -rf lib', 'tsc'), <%_ } _%> lint: concurrent(linters), test, <%_ if (mocha) { _%> mocha, <%_ } _%> }, }