I have some gulp tasks to run my TSLint checks for a project. I have a task to only watch the newly changed files and run the checks for these when they change (upon file save). Currently when I run the watchTS
task, it will run and work fine upon the first file I save/change. Upon the next file change it will run the task but not actually complete or do any TSLint validation.
Gulp Output
[09:49:34] Starting 'watchTS'...
[09:49:35] Finished 'watchTS' after 692 ms
[09:49:36] Starting 'tslint:newer'...
Running - tslint:newer
[09:49:36] [gulp-tslint] error example.controller.ts[13, 8]: unused variable: 'x'
[09:49:36] Finished 'tslint:newer' after 738 ms
[09:53:38] Starting 'tslint:newer'...
Running - tslint:newer
It runs once, and finds an error. I do something to make it run again, and it never finishes the task or runs TSLint.
Here are the relevant gulp tasks
var BIN = "bin";
var TYPE_SCRIPT_FILES = ["app/**/*.ts"];
var TYPE_SCRIPT_CONFIG = tslint({
rulesDirectory: "tslint-rules/"
});
var TYPE_SCRIPT_REPORT = tslint.report("prose", {
emitError: false,
reportLimit: 50
});
gulp.task("tslint:newer", function () {
console.log("Running - tslint:newer");
return gulp.src(TYPE_SCRIPT_FILES)
.pipe(plumber())
.pipe(newer(BIN))
.pipe(TYPE_SCRIPT_CONFIG)
.pipe(TYPE_SCRIPT_REPORT)
.pipe(gulp.dest(BIN));
});
gulp.task("watchTS", [], function () {
gulp.watch(TYPE_SCRIPT_FILES, ["tslint:newer"]);
});