chokidar icon indicating copy to clipboard operation
chokidar copied to clipboard

chokidar does not fire events for .swp files.

Open george-thomas-hill opened this issue 3 years ago • 2 comments

Describe the bug

chokidar does not fire events for .swp files.

Versions (please complete the following information):

  • Chokidar version 3.5.3
  • Node version 16.11.0
  • OS version: Kubuntu 21.04

To Reproduce:

  1. Create the following .js file:
let chokidar = require('chokidar');
const directory = ".";
const options = {
    depth: 0,
};
let watcher = chokidar.watch(directory, options);
watcher.on('all', handleAll);
function handleAll(event, path) {
    console.log(`${event}: ${path}`);
}
watcher.on("ready", handleReady);
function handleReady() {
    console.log("Ready!");
}
  1. Run that file.

  2. In the same directory, cause a .swp file to be created by opening a file with nano (or, I suspect, vim):

nano test.txt
  1. In the same directory, list all the files that the OS sees:
$ ls -la
total 40
drwxrwxr-x  3 georgehill georgehill  4096 Feb  4 12:31 .
drwxrwxr-x 25 georgehill georgehill  4096 Jan  2 08:28 ..
drwxrwxr-x 16 georgehill georgehill  4096 Feb  4 12:30 node_modules
-rw-rw-r--  1 georgehill georgehill   273 Feb  4 12:30 package.json
-rw-rw-r--  1 georgehill georgehill 10784 Feb  4 12:30 package-lock.json
-rw-rw-r--  1 georgehill georgehill    16 Feb  4 12:21 test.txt
-rw-rw-r--  1 georgehill georgehill  1024 Feb  4 12:31 .test.txt.swp
-rw-rw-r--  1 georgehill georgehill   336 Feb  4 12:22 test-watching-dotfiles.js
  1. Observe the events that chokidar fires:
$ node test-watching-dotfiles.js 
addDir: .
add: package-lock.json
add: package.json
add: test-watching-dotfiles.js
add: test.txt
addDir: node_modules
Ready!

Expected behavior

I would expect the file that is running chokidar to show add events for the file ".test.txt.swp", since that file shows up when I use "ls -la".

Additional context

None.

george-thomas-hill avatar Feb 04 '22 17:02 george-thomas-hill

See readme, docs

paulmillr avatar Feb 04 '22 17:02 paulmillr

I have read the README.md file and I don't find anything about .swp files (and I can't find other documentation).

What do I need to know about how chokidar handles .swp files?

Thank you.

george-thomas-hill avatar Feb 04 '22 17:02 george-thomas-hill