Forráskód Böngészése

[create-stdf]Fix file path

杜府 3 éve
szülő
commit
8aa2381e9a

+ 1 - 1
packages/create-stdf/package.json

@@ -1,6 +1,6 @@
 {
     "name": "create-stdf",
-    "version": "0.0.18",
+    "version": "0.0.19",
     "description": "A CLI for creating new STDF projects",
     "bin": {
         "create-stdf": "index.js"

+ 4 - 4
packages/create-stdf/src/index.js

@@ -110,11 +110,11 @@ templateOptions.forEach(async item => {
         fs.mkdirSync(projectDir);
         // 获取模板目录的绝对路径,考虑到 Windows 系统的兼容性, 使用 path.join
         // Get the absolute path of the template directory, considering the compatibility of the Windows system, use path.join
-        const filePath = path.join(path.resolve(), item.template);
+        const templatePath = path.join(new URL(item.template, import.meta.url).pathname);
 
-        // 将 filePath 目录下的所有文件复制到 projectDir 目录下
-        // Copy all files under the filePath directory to the projectDir directory\
-        fs.copy(filePath, projectDir)
+        // 将 templatePath 目录下的所有文件复制到 projectDir 目录下
+        // Copy all files under the templatePath directory to the projectDir directory\
+        fs.copy(templatePath, projectDir)
             .then(() => {
                 spinner.stop();
                 console.log(`🎉 ${lang.pcsucc}