profile
viewpoint

Ask questionswatch task is always run on initialization, regardless of ignoreinitial option value and file system contents

What were you expecting to happen?

Nothing

What actually happened?

Watch task ran during initialization

Please give us a sample of your gulpfile

const { watch } = require("gulp");

function watchAction(foo) {
  console.log("foo=", foo);
}

function testingTask(cb) {
  watch("../.mydir/.myfile", { events: "add", ignoreinitial: true }, watchAction(true));
  cb();
}

exports.testing = testingTask;

Terminal output / screenshots

<!-- We need to understand what you are seeing in your terminal, so please copy the output (or screenshots of the output) below. -->

$ gulp testing

[10:20:53] Using gulpfile D:\temp\gulpfile.js
[10:20:53] Starting 'testing'...
foo= true
[10:20:53] Finished 'testing' after 19 ms

Please provide the following information:

  • OS: Windows 10 x64 v20H2 (OS Build 19042.985)
  • node: 14.16.0
  • npm: 6.14.1
  • gulp: CLI version: 2.3.0, Local version: 4.0.2

Additional information

N/A

gulpjs/gulp

Answer questions pm64

Brilliant, thank you @simonhammes

useful!
source:https://uonfu.com/
Github User Rank List