diff --git a/.github/workflows/linux-10.yml b/.github/workflows/linux-10.yml deleted file mode 100644 index fba143ae..00000000 --- a/.github/workflows/linux-10.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CI-Linux-10 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - schedule: - - cron: '0 2 * * *' - workflow_dispatch: {} - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [10] - os: [ubuntu-latest] - - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i npminstall -g && npminstall - - - name: Continuous Integration - run: npm run ci - - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/linux-12.yml b/.github/workflows/linux-12.yml deleted file mode 100644 index 634ceaff..00000000 --- a/.github/workflows/linux-12.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CI-Linux-12 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - schedule: - - cron: '0 2 * * *' - workflow_dispatch: {} - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [12] - os: [ubuntu-latest] - - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i npminstall -g && npminstall - - - name: Continuous Integration - run: npm run ci - - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/linux-14.yml b/.github/workflows/linux-14.yml deleted file mode 100644 index d73e0640..00000000 --- a/.github/workflows/linux-14.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CI-Linux-14 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - schedule: - - cron: '0 2 * * *' - workflow_dispatch: {} - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [14] - os: [ubuntu-latest] - - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i npminstall -g && npminstall - - - name: Continuous Integration - run: npm run ci - - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/linux-8.yml b/.github/workflows/linux-8.yml deleted file mode 100644 index 09bf93fe..00000000 --- a/.github/workflows/linux-8.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CI-Linux-8 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - schedule: - - cron: '0 2 * * *' - workflow_dispatch: {} - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [8] - os: [ubuntu-latest] - - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i npminstall -g && npminstall - - - name: Continuous Integration - run: npm run ci - - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml new file mode 100644 index 00000000..229ccbff --- /dev/null +++ b/.github/workflows/nodejs.yml @@ -0,0 +1,44 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: + - master + pull_request: + branches: + - master + schedule: + - cron: '0 2 * * *' + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + node-version: [8, 10, 12, 14, 16] + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - name: Checkout Git Source + uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install Dependencies + run: npm i -g npminstall && npminstall + + - name: Continuous Integration + run: npm run ci + + - name: Code Coverage + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/osx-10.yml b/.github/workflows/osx-10.yml deleted file mode 100644 index 850fd3f1..00000000 --- a/.github/workflows/osx-10.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CI-OSX-10 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - schedule: - - cron: '0 2 * * *' - workflow_dispatch: {} - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [10] - os: [macos-latest] - - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i npminstall -g && npminstall - - - name: Continuous Integration - run: npm run ci - - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/osx-12.yml b/.github/workflows/osx-12.yml deleted file mode 100644 index 382e9c76..00000000 --- a/.github/workflows/osx-12.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CI-OSX-12 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - schedule: - - cron: '0 2 * * *' - workflow_dispatch: {} - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [12] - os: [macos-latest] - - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i npminstall -g && npminstall - - - name: Continuous Integration - run: npm run ci - - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/osx-14.yml b/.github/workflows/osx-14.yml deleted file mode 100644 index ebcb9dc6..00000000 --- a/.github/workflows/osx-14.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CI-OSX-14 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - schedule: - - cron: '0 2 * * *' - workflow_dispatch: {} - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [14] - os: [macos-latest] - - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i npminstall -g && npminstall - - - name: Continuous Integration - run: npm run ci - - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/osx-8.yml b/.github/workflows/osx-8.yml deleted file mode 100644 index 6cdd930c..00000000 --- a/.github/workflows/osx-8.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CI-OSX-8 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - schedule: - - cron: '0 2 * * *' - workflow_dispatch: {} - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [8] - os: [macos-latest] - - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i npminstall -g && npminstall - - - name: Continuous Integration - run: npm run ci - - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/windows-10.yml b/.github/workflows/windows-10.yml deleted file mode 100644 index eea012dd..00000000 --- a/.github/workflows/windows-10.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CI-Windows-10 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - schedule: - - cron: '0 2 * * *' - workflow_dispatch: {} - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [10] - os: [windows-latest] - - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i npminstall -g && npminstall - - - name: Continuous Integration - run: npm run ci - - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/windows-12.yml b/.github/workflows/windows-12.yml deleted file mode 100644 index aa49827f..00000000 --- a/.github/workflows/windows-12.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CI-Windows-12 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - schedule: - - cron: '0 2 * * *' - workflow_dispatch: {} - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [12] - os: [windows-latest] - - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i npminstall -g && npminstall - - - name: Continuous Integration - run: npm run ci - - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/windows-14.yml b/.github/workflows/windows-14.yml deleted file mode 100644 index 71539b4f..00000000 --- a/.github/workflows/windows-14.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CI-Windows-14 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - schedule: - - cron: '0 2 * * *' - workflow_dispatch: {} - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [14] - os: [windows-latest] - - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i npminstall -g && npminstall - - - name: Continuous Integration - run: npm run ci - - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/windows-8.yml b/.github/workflows/windows-8.yml deleted file mode 100644 index b10663c1..00000000 --- a/.github/workflows/windows-8.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CI-Windows-8 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - schedule: - - cron: '0 2 * * *' - workflow_dispatch: {} - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [8] - os: [windows-latest] - - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i npminstall -g && npminstall - - - name: Continuous Integration - run: npm run ci - - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index a7eb4faa..210c2eea 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ You can pass any mocha argv. - `--typescript` / `--ts` enable typescript support, default to `false`. - `--changed` / `-c` only test changed test files(test files means files that match `${pwd}/test/**/*.test.(js|ts)`) - `--dry-run` / `-d` whether dry-run the test command, just show the command +- `--espower` / `-e` whether auto require intelli-espower-loader(js) or espower-typescript(ts) for power-assert, default to `true`. - see more at https://mochajs.org/#usage #### environment diff --git a/lib/cmd/test.js b/lib/cmd/test.js index 3dfef01a..ed70b479 100644 --- a/lib/cmd/test.js +++ b/lib/cmd/test.js @@ -39,6 +39,12 @@ class TestCommand extends Command { description: 'whether show test command, no test will be executed', alias: 'd', }, + espower: { + type: 'boolean', + description: 'whether require intelli-espower-loader(js) or espower-typescript(ts) for power-assert', + default: true, + alias: 'e', + }, }; } @@ -104,12 +110,12 @@ class TestCommand extends Command { if (requireArr.includes('intelli-espower-loader')) { console.warn('[egg-bin] don\'t need to manually require `intelli-espower-loader` anymore'); - } else { + } else if (testArgv.espower) { requireArr.push(require.resolve('intelli-espower-loader')); } // for power-assert - if (testArgv.typescript) { + if (testArgv.typescript && testArgv.espower) { const tscompilerPath = require.resolve(testArgv.tscompiler); requireArr.splice(requireArr.indexOf(tscompilerPath), 1); requireArr.push(tscompilerPath, require.resolve('../espower-typescript')); @@ -162,6 +168,7 @@ class TestCommand extends Command { testArgv.r = undefined; testArgv.t = undefined; testArgv.g = undefined; + testArgv.e = undefined; testArgv.typescript = undefined; testArgv['dry-run'] = undefined; testArgv.dryRun = undefined; diff --git a/test/lib/cmd/test.test.js b/test/lib/cmd/test.test.js index e264dac4..0e8e0dfd 100644 --- a/test/lib/cmd/test.test.js +++ b/test/lib/cmd/test.test.js @@ -107,17 +107,56 @@ describe('test/lib/cmd/test.test.js', () => { .end(done); }); - it('should warn when require intelli-espower-loader', () => { - mm(process.env, 'TESTS', 'test/power-assert-fail.js'); - return coffee.fork(eggBin, [ 'test', '-r', 'intelli-espower-loader' ], { cwd }) - // .coverage(false) - // .debug() - .expect('stderr', /manually require `intelli-espower-loader`/) - .expect('stdout', /1\) should fail/) - .expect('stdout', /assert\(1 === 2\)/) - .expect('stdout', /1 failing/) - .expect('code', 1) - .end(); + describe('intelli-espower-loader', () => { + it('should warn when require intelli-espower-loader', () => { + mm(process.env, 'TESTS', 'test/power-assert-fail.js'); + return coffee.fork(eggBin, [ 'test', '-r', 'intelli-espower-loader' ], { cwd }) + // .coverage(false) + // .debug() + .expect('stderr', /manually require `intelli-espower-loader`/) + .expect('stdout', /1\) should fail/) + .expect('stdout', /assert\(1 === 2\)/) + .expect('stdout', /1 failing/) + .expect('code', 1) + .end(); + }); + + it('should default require intelli-espower-loader', () => { + mm(process.env, 'TESTS', 'test/power-assert-fail.js'); + return coffee.fork(eggBin, [ 'test', '--dry-run' ], { cwd }) + // .coverage(false) + // .debug() + .expect('stdout', /--require=.*intelli-espower-loader\.js/) + .end(); + }); + + it('should not require intelli-espower-loader with --espower=false', () => { + mm(process.env, 'TESTS', 'test/power-assert-fail.js'); + return coffee.fork(eggBin, [ 'test', '--espower=false', '--dry-run' ], { cwd }) + // .coverage(false) + // .debug() + .notExpect('stdout', /--require=.*intelli-espower-loader\.js/) + .end(); + }); + + it('should default require espower-typescript when typescript', () => { + mm(process.env, 'TESTS', 'test/power-assert-fail.js'); + return coffee.fork(eggBin, [ 'test', '--typescript', '--dry-run' ], { cwd }) + // .coverage(false) + // .debug() + .expect('stdout', /--require=.*espower-typescript\.js/) + .end(); + }); + + it('should not require ntelli-espower-loader/espower-typescript when typescript with --espower=false', () => { + mm(process.env, 'TESTS', 'test/power-assert-fail.js'); + return coffee.fork(eggBin, [ 'test', '--typescript', '--espower=false', '--dry-run' ], { cwd }) + // .coverage(false) + // .debug() + .notExpect('stdout', /--require=.*intelli-espower-loader\.js/) + .notExpect('stdout', /--require=.*espower-typescript\.js/) + .end(); + }); }); it('should auto require test/.setup.js', () => {