gpt4 book ai didi

javascript - Gulp Watch 未调用关联的 gulp 任务

转载 作者:行者123 更新时间:2023-11-28 05:23:18 26 4
gpt4 key购买 nike

因此,在(长时间)休息后,我将回到个人项目,并且我将回到事情的流程中。让我印象深刻的一件事是我的观察者没有工作。例如,如果我调用 gulp watch-for-jshint ,我希望每当我修改 JS 文件时 JSHint 都会发生更改——无论是根文件 (gulp.js) 还是我的客户端应用程序文件之一 (./client-app/js/controllers/register.js)。那并没有发生。我可以看到 watch 正在启动,但当我更改文件时它永远不会调用 JSHint!

有人知道出了什么问题或如何诊断吗?据我所知,我的语法是正确的...并且因为(出于测试目的)我直接调用 watch-for-jshint,所以我应该避免从未真正调用我的观察者的常见陷阱。

简化的 gulp 文件:

var gulp = require('gulp'),
clean = require('gulp-clean'),
jshint = require('gulp-jshint'),
notify = require('gulp-notify'),
watch = require('gulp-watch'),

gulp.task('jshint', function(){
console.log("Running JSHint");
return gulp.src(['*.js', 'client-app/**/*.js'], ['jshint'])
.pipe(jshint({"moz":true}))
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'))
.on('error', notify.onError({ sound: "Funk" }));
});

gulp.task('watch-for-jshint', function(){
return watch(['*.js', './client-app/**/*.js'], ['jshint']);
});

我删去了很多无关的任务,但上面的内容应该是所有相关的。

最佳答案

自然地,发布后 5 分钟,我注意到我的语法与许多问题所使用的语法之间存在差异。大多数人都在使用 gulp.watch,我只是遵循 gulp-watch NPM module 中找到的语法。仅使用watch的页面。

不...完全确定为什么一个有效而另一个无效;奇怪的。似乎新版本不应该工作,因为它没有引用 gulp-watch 模块。

关于javascript - Gulp Watch 未调用关联的 gulp 任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40373233/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com