直到Gulp为止,我从未尝试执行CLI命令。我想做的是:
gulp watch
来监视* js文件中的更改browserify
CLI命令将我的main.js
重建为build.js
文件。gulp-shell
通过gulp
实现以上目标。gulpfile.js
文件var gulp = require("gulp");
var shell = require('gulp-shell');
gulp.task('browserify-changes', shell.task('browserify js/main.js -o js/build.js -d'));
gulp.task('watch', function() {
gulp.watch('js/*.js', gulp.series('browserify-changes'));
});
显然,如果我通过bash直接执行CLI命令
browserify js/main.js -o js/build.js -d
,则可以正常工作。
当我希望通过gulp watch
发生相同的事情时,我会得到:
...
[1] [09:40:48] Using gulpfile D:\workspace\fun\gulpfile.js
[1] [09:40:48] Starting 'watch'...
[1] [09:40:54] Starting 'browserify-changes'...
[1] [09:40:55] Finished 'browserify-changes' after 305 ms
[1] [09:40:55] Starting 'browserify-changes'...
[1] [09:40:55] Finished 'browserify-changes' after 295 ms
[1] [09:40:55] Starting 'browserify-changes'...
[1] [09:40:56] Finished 'browserify-changes' after 307 ms
[1] [09:40:56] Starting 'browserify-changes'...
[1] [09:40:56] Finished 'browserify-changes' after 301 ms
[1] [09:40:56] Starting 'browserify-changes'...
[1] [09:40:57] Finished 'browserify-changes' after 302 ms
[1] [09:40:57] Starting 'browserify-changes'...
... and on
... and on until my bash goes crazy
请注意:我已经尝试了Internet上所有其他可用的插件(例如gulp-shell
),但我的问题没有改变。
请帮助我了解我在做什么错以及如何解决?
谢谢