我正在使用npm链接来链接此项目中的其他包现在当该包更新时我想使用自动监视功能并重新启动应用程序。
如何观察节点模块的更改?
gulp.js
var gulp = require("gulp");
var ts = require("gulp-typescript");
var uglify = require("gulp-uglifyes");
var gulpif = require("gulp-if");
var log = require("fancy-log");
var nodemon = require('gulp-nodemon');
var tsProject = ts.createProject("tsconfig.json");
gulp.task("default", () => {
return tsProject.src().pipe(tsProject()).pipe(gulpif(arg.env === 'prod', uglify())).pipe(gulp.dest("dist"));
});
gulp.task('stream', ['default'], function develop() {
var stream = nodemon({
script: 'server.js',
ext: 'js',
watch: "../project/local",
ignore: ['ignored.js'],
tasks: ["default"]
}) return stream.on('restart', function() {
console.log('restarting nodemon')
}).on('crash', function() {
console.error('Application has crashed!\n') stream.emit('restart', 10)
})
})