Skip to content

Re-watching a path does not honour ignoreInitial #1386

@TobyEalden

Description

@TobyEalden

Describe the bug
This is a duplicate of #1185, which has been closed, however the test case still fails.

With ignoreInitial set to false, when first adding a directory all the initial files are emitted. If the directory is un-watched and then watched again at some point in the future, the initial files are not emitted.

Versions (please complete the following information):

  • Chokidar version 4.0.1
  • Node version 18.18.2
  • OS version: macOS 15.1

To Reproduce:

import chokidar from "chokidar";
const directory = ".";
const options = {
  disableGlobbing: true,
  depth: 0,
};
let watcher = chokidar.watch(directory, options);
watcher.on("all", handleAll);
function handleAll(event, path) {
  console.log(`${event}: ${path}`);
}
watcher.on("ready", handleReady);
async function handleReady() {
  console.log("Ready!");
  await watcher.unwatch(directory);
  console.log("Unwatched!");
  watcher.add(directory);
  console.log("Re-watched!");
}

Expected behavior
Un-watching and then re-watching a directory should cause the initial files to be emitted if ignoreInitial is false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions