chokidar
chokidar copied to clipboard
Paths with parentheses () are not watched - globbing issue
Describe the bug
When I try to add a path with parentheses (f.e. "C:/Demo Projects/Test (1)" ) to be watched by Chokidar it returns with "filepath is not defined" error on add event. Escaping special characters does not help.
Versions (please complete the following information):
- Chokidar version: 3.3.1
- OS version: Windows 10
To Reproduce:
const chokidar = require('chokidar');
const fs = require('fs');
chokidar.watch("C:/Demo Projects/Test \\(1\\)", {}).on("add", filepath => handleNewAdded(config, filepath));
Observed behavior Chokidar returns with "filepath is not defined" error on add event.
Expected behavior A folder path with parentheses (1) is being successfully watched.
that path seems like invalid glob to me
How so? It's a common scenario where duplicate folder f.e. from unzipping, would get (x)
suffix appended to its name by Windows.
How else can this path be escaped to pass glob test?
Windows doesn't use /
in paths, it uses \
.
How else can this path be escaped to pass glob test?
not sure
Have you tried this variation?
chokidar.watch("C:/Demo Projects/Test \(1\)", {}).on("add", filepath => handleNewAdded(config, filepath));
AFAIK, the backslash escapes the character that follows it, so I believe the double backslashes you had earlier were getting translated into this path: C:\Demo Projects\Test \(1\)
, or to make it clearer:
C:\
Demo Projects\
Test \
(1\
)\
Has this issue been resolved? Is there a fix? I'm still having trouble trying to watch a path which contains the left parentheses "(".