From c6d221d7ef3dd9ae11cb1295071f113643e5d446 Mon Sep 17 00:00:00 2001 From: "Congcong Cai (EE-CN-42)" Date: Mon, 2 May 2022 09:34:19 +0800 Subject: [PATCH] fix: support windows format path (#2262) --- cli/index.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cli/index.js b/cli/index.js index 53d85a9a7a..c9472142d0 100644 --- a/cli/index.js +++ b/cli/index.js @@ -643,17 +643,18 @@ export async function main(argv, options) { // Include entry files for (let i = 0, k = argv.length; i < k; ++i) { - const filename = argv[i]; - let sourcePath = String(filename) - .replace(/\\/g, "/") - .replace(extension_re, "") - .replace(/[\\/]$/, ""); + const filename = String(argv[i]); // Setting the path to relative path - sourcePath = path.isAbsolute(sourcePath) - ? path.relative(baseDir, sourcePath).replace(/\\/g, "/") - : sourcePath; + let sourcePath = path.isAbsolute(filename) + ? path.relative(baseDir, filename) + : path.normalize(filename); + sourcePath = sourcePath + .replace(/\\/g, "/") + .replace(extension_re, "") + .replace(/\/$/, ""); + // Try entryPath.ext, then entryPath/index.ext let sourceText = await readFile(sourcePath + extension, baseDir); if (sourceText == null) {