From 15ce2d2442fda92aaeaab910aeb37e480451acaa Mon Sep 17 00:00:00 2001 From: mshanemc Date: Thu, 28 Jul 2022 17:59:38 -0500 Subject: [PATCH] fix: globs don't like windows paths --- src/shared/fs.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/shared/fs.ts b/src/shared/fs.ts index 8c79e044..b390e918 100644 --- a/src/shared/fs.ts +++ b/src/shared/fs.ts @@ -16,12 +16,15 @@ const getObjectXmlByPathAsJson = async (objectFilePath: string): Promise(xml, 'CustomObject'); }; +/** globs don't support windows path, but the input might be */ +const ensurePosixPath = (filePath: string): string => filePath.split(path.sep).join(path.posix.sep); + /** * @param targetPaths typically your pkgDirs or project path * @returns directories that end in `/objects/` */ export const getDirectoriesThatContainObjects = async (targetPaths: string[]): Promise => { - const globs = targetPaths.map((p) => `${p}/**/objects/`); + const globs = targetPaths.map((p) => `${ensurePosixPath(p)}/**/objects/`); return fg(globs, { onlyDirectories: true }); }; @@ -30,7 +33,7 @@ export const getDirectoriesThatContainObjects = async (targetPaths: string[]): P * @returns directories that are children of `/objects/` like `force-app/main/default/objects/Foo__c` */ export const getObjectDirectories = async (targetPaths: string[]): Promise => { - const globs = targetPaths.map((p) => `${p}/**/objects/*`); + const globs = targetPaths.map((p) => `${ensurePosixPath(p)}/**/objects/*`); return await fg(globs, { onlyDirectories: true }); }; @@ -39,7 +42,7 @@ export const getObjectDirectories = async (targetPaths: string[]): Promise => { - const globs = `${folder}/*.object-meta.xml`; + const globs = `${ensurePosixPath(folder)}/*.object-meta.xml`; const [objectMetaPath] = await fg(globs); return getObjectXmlByPathAsJson(objectMetaPath); };