chokidar icon indicating copy to clipboard operation
chokidar copied to clipboard

Paths with parentheses () are not watched - globbing issue

Open szalap opened this issue 4 years ago • 6 comments

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.

szalap avatar Mar 04 '20 18:03 szalap

that path seems like invalid glob to me

paulmillr avatar Mar 06 '20 07:03 paulmillr

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?

szalap avatar Mar 25 '20 11:03 szalap

Windows doesn't use / in paths, it uses \.

paulmillr avatar Mar 25 '20 11:03 paulmillr

How else can this path be escaped to pass glob test?

not sure

paulmillr avatar Mar 25 '20 11:03 paulmillr

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\
                )\

proimage avatar Jul 30 '20 13:07 proimage

Has this issue been resolved? Is there a fix? I'm still having trouble trying to watch a path which contains the left parentheses "(".

Virgil993 avatar Nov 22 '23 12:11 Virgil993