1
我需要構建一個開發環境,它將自動編譯,運行測試,然後在./src/
或./test/
中的.ts
文件發生變化時運行TSLint,並打印出測試結果和皮棉。當任何文件發生變化時,使用TypeScript和Mocha自動運行測試
./src/*.ts --\ (tsc --watch) (mocha --watch)
|---------------> ./lib/ ---------------> console.log
./test/*.ts --/ |
| (tslint --watch)
|--------------------> console.log
我已經寫了NPM腳本與npm run test
只運行一次這個工作流程:
// package.json
{
"scripts": {
"pretest": "tsc", // will compile *.ts in src/ and test/ to lib/
"test": "mocha --reporter spec --full-trace lib/test/tests.js", // run the compiled test file
"posttest": "gulp tslint" // run gulp for tslint
}
}
我寫了一大口的任務看文件更改觸發故宮腳本:
// gulpfile.js
var exec = require('gulp-exec');
gulp.task("watch",() => {
gulp.watch(paths.scripts,() => {
exec(`npm run test`, {
continueOnError: true,
pipeStdout: true
})
});
});
我跑gulp watch
,但我並沒有顯示在控制檯測試和皮棉的結果。
如何實現我的目標,這將運行TS-編譯,摩卡測試,然後TS-皮棉當任何*.ts
文件的變化?
你有'scirpts'一個錯字,它應該是'scripts'。 – mixel