From 0396ba12f035c7bb326a75354b2db331143f7304 Mon Sep 17 00:00:00 2001 From: Huihui Wu Date: Mon, 8 Jul 2024 13:45:45 +0800 Subject: [PATCH] fix: import SPFx project fail due to case sensitive file system on ubuntu --- .../component/generator/spfx/spfxGenerator.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/fx-core/src/component/generator/spfx/spfxGenerator.ts b/packages/fx-core/src/component/generator/spfx/spfxGenerator.ts index 8b3489d97d..f767df2d40 100644 --- a/packages/fx-core/src/component/generator/spfx/spfxGenerator.ts +++ b/packages/fx-core/src/component/generator/spfx/spfxGenerator.ts @@ -649,23 +649,24 @@ export class SPFxGenerator { return undefined; } - const webpartName = webparts[0].split(path.sep).pop(); - const webpartManifestPath = path.join( - webpartsDir, - webparts[0], - `${webpartName as string}WebPart.manifest.json` + const webpartManifest = (await fs.readdir(path.join(webpartsDir, webparts[0]))).find((file) => + file.endsWith("WebPart.manifest.json") ); - if (!(await fs.pathExists(webpartManifestPath))) { + if (webpartManifest === undefined) { throw new FileNotFoundError( Constants.PLUGIN_NAME, - webpartManifestPath, + path.join( + webpartsDir, + webparts[0], + `${webparts[0].split(path.sep).pop() as string}WebPart.manifest.json` + ), Constants.IMPORT_HELP_LINK ); } const matchHashComment = new RegExp(/(\/\/ .*)/, "gi"); const manifest = JSON.parse( - (await fs.readFile(webpartManifestPath, "utf8")) + (await fs.readFile(path.join(webpartsDir, webparts[0], webpartManifest), "utf8")) .toString() .replace(matchHashComment, "") .trim()