diff --git a/cli/src/utils.spec.ts b/cli/src/utils.spec.ts index 3e7e55fcb69e1..93f031872be7e 100644 --- a/cli/src/utils.spec.ts +++ b/cli/src/utils.spec.ts @@ -6,6 +6,7 @@ interface Test { test: string; options: Omit; files: Record; + skipOnWin32?: boolean; } const cwd = process.cwd(); @@ -48,6 +49,18 @@ const tests: Test[] = [ '/photos/image.jpg': true, }, }, + { + test: 'should crawl folders with quotes', + options: { + pathsToCrawl: ["/photo's/", '/photo"s/', '/photo`s/'], + }, + files: { + "/photo's/image1.jpg": true, + '/photo"s/image2.jpg': true, + '/photo`s/image3.jpg': true, + }, + skipOnWin32: true, // single quote interferes with mockfs root on Windows + }, { test: 'should crawl a single file', options: { @@ -270,8 +283,12 @@ describe('crawl', () => { }); describe('crawl', () => { - for (const { test, options, files } of tests) { - it(test, async () => { + for (const { test: name, options, files, skipOnWin32 } of tests) { + if (process.platform === 'win32' && skipOnWin32) { + test.skip(name); + continue; + } + it(name, async () => { // The file contents is the same as the path. mockfs(Object.fromEntries(Object.keys(files).map((file) => [file, file]))); diff --git a/cli/src/utils.ts b/cli/src/utils.ts index 7bbbb5615b640..27cc2f9e082a7 100644 --- a/cli/src/utils.ts +++ b/cli/src/utils.ts @@ -146,7 +146,7 @@ export const crawl = async (options: CrawlOptions): Promise => { } const searchPatterns = patterns.map((pattern) => { - let escapedPattern = pattern; + let escapedPattern = pattern.replaceAll("'", "[']").replaceAll('"', '["]').replaceAll('`', '[`]'); if (recursive) { escapedPattern = escapedPattern + '/**'; }