function testEnv(script) {
  return crossEnv(`NODE_ENV=test ${script}`)
}
示例#2
0
const {series, crossEnv, concurrent, rimraf} = require('nps-utils')

module.exports = {
  scripts: {
    default: 'nps webpack',
    test: {
      default: 'nps test.jest',
      jest: {
        default: series(
          rimraf('test/coverage-jest'),
          crossEnv('BABEL_TARGET=node jest')
        ),
        accept: crossEnv('BABEL_TARGET=node jest -u'),
        watch: crossEnv('BABEL_TARGET=node jest --watch'),
      },

      karma: {
        default: series(
          rimraf('test/coverage-karma'),
          'karma start test/karma.conf.js'
        ),
        watch: 'karma start test/karma.conf.js --auto-watch --no-single-run',
        debug: 'karma start test/karma.conf.js --auto-watch --no-single-run --debug'
      },

      lint: {
        default: 'eslint src',
        fix: 'eslint src --fix'
      },
      all: concurrent({
        browser: series.nps('test.karma'),
const {series, rimraf, commonTags, crossEnv, concurrent} = require('nps-utils')

const hiddenFromHelp = true

module.exports = {
  scripts: {
    default: {
      description: 'run the production server on the build directory',
      script: 'pushstate-server build',
    },
    dev: {
      description: 'run the dev server',
      script: crossEnv(
        `PORT=${process.env.PORT || '8080'} react-scripts start`
      ),
    },
    build: {
      description: 'run the build',
      script: 'react-scripts build',
    },
    test: {
      default: {
        description: 'run both the unit and integrationt tests in parallel',
        script: concurrent.nps('test.unit', 'test.integration'),
      },
      unit: {
        default: {
          description: 'run the unit tests and collect code coverage',
          script: testEnv(
            'jest --config=tests/jest.config.unit.json --coverage'
          ),
       'nps webpack.build.before',
       'webpack --progress -d'
     ),
     extractCss: series(
       'nps webpack.build.before',
       'webpack --progress -d --env.extractCss'
     ),
     serve: series.nps(
       'webpack.build.development',
       'serve'
     ),
   },
   production: {
     inlineCss: series(
       'nps webpack.build.before',
       crossEnv('NODE_ENV=production webpack --progress -p --env.production')
     ),
     default: series(
       'nps webpack.build.before',
       crossEnv('NODE_ENV=production webpack --progress -p --env.production --env.extractCss')
     ),
     serve: series.nps(
       'webpack.build.production',
       'serve'
     ),
   }
 },
 server: {
   default: `webpack-dev-server -d --devtool '#source-map' --inline --env.server`,
   extractCss: `webpack-dev-server -d --devtool '#source-map' --inline --env.server --env.extractCss`,
   hmr: `webpack-dev-server -d --devtool '#source-map' --inline --hot --env.server`