mirror of
https://github.com/immich-app/immich.git
synced 2025-03-25 02:41:37 -05:00
fix(cli): handle folders with single quotes (#15283)
* fix(cli): handle folders with single quotes * fix(cli): skip single quote test on Windows * fix(cli): support double quote and backtick as well
This commit is contained in:
parent
abf5b0afe1
commit
c4a8fdf0f3
2 changed files with 20 additions and 3 deletions
|
@ -6,6 +6,7 @@ interface Test {
|
||||||
test: string;
|
test: string;
|
||||||
options: Omit<CrawlOptions, 'extensions'>;
|
options: Omit<CrawlOptions, 'extensions'>;
|
||||||
files: Record<string, boolean>;
|
files: Record<string, boolean>;
|
||||||
|
skipOnWin32?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cwd = process.cwd();
|
const cwd = process.cwd();
|
||||||
|
@ -48,6 +49,18 @@ const tests: Test[] = [
|
||||||
'/photos/image.jpg': true,
|
'/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',
|
test: 'should crawl a single file',
|
||||||
options: {
|
options: {
|
||||||
|
@ -270,8 +283,12 @@ describe('crawl', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('crawl', () => {
|
describe('crawl', () => {
|
||||||
for (const { test, options, files } of tests) {
|
for (const { test: name, options, files, skipOnWin32 } of tests) {
|
||||||
it(test, async () => {
|
if (process.platform === 'win32' && skipOnWin32) {
|
||||||
|
test.skip(name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
it(name, async () => {
|
||||||
// The file contents is the same as the path.
|
// The file contents is the same as the path.
|
||||||
mockfs(Object.fromEntries(Object.keys(files).map((file) => [file, file])));
|
mockfs(Object.fromEntries(Object.keys(files).map((file) => [file, file])));
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ export const crawl = async (options: CrawlOptions): Promise<string[]> => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchPatterns = patterns.map((pattern) => {
|
const searchPatterns = patterns.map((pattern) => {
|
||||||
let escapedPattern = pattern;
|
let escapedPattern = pattern.replaceAll("'", "[']").replaceAll('"', '["]').replaceAll('`', '[`]');
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
escapedPattern = escapedPattern + '/**';
|
escapedPattern = escapedPattern + '/**';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue