node.js - gulp文件监听的问题
高洛峰
高洛峰 2017-04-17 15:22:46
0
1
368

我最近发现gulp-watch这个组件,不知道是我哪里的问题,在linux,windows上表现不一样,为什么在windows10上,我修改一个文件,他会先删除刚修改的文件,再添加一次,而linux 则会只是修改文件。并且windows上经常报错,要不就是运行一会之后,就变得监听就变得卡卡的,修改一个网页都要半天。。。本人英语不好,不好直接去github上反应。。期望有大牛能说说么?
我的gulp脚本

gulp.task('static-sync:dev', ['static-sync'], function () {
  util.log('[Sync] starting file watch');
  return watch(config.static, function (obj) {
    if (obj.event === 'change' || obj.event === 'add')
      return gulp.src(obj.path, {base: './'})
          .pipe(gulp.dest(config.dist))
          .pipe(print(function () {
            return '[Sync] file sync success: ' + obj.path.replace(obj.base, '');
          }));
    else if (obj.event === 'unlink') {
      var distFilePath = obj.path.replace(__dirname, __dirname + '/' + config.dist);
      return gulp.src(distFilePath)
          .pipe(clean())
          .pipe(print(function () {
            return '[Sync] file remove success: ' + obj.path.replace(obj.base, '');
          }));
    }
  });
});

windows上每一次修改都会进入 删除和修改两个监听,一共三次事件,而linux则为一次。。。很疑惑。。

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
Ty80

This problem is about webstorm's secure reading and writing. You need to turn off this secure reading and writing, otherwise compilation problems may occur.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template