优化本地文件打包功能

This commit is contained in:
Tlntin
2022-12-29 11:24:22 +08:00
parent c7717ffda5
commit 2f9e104b51
6 changed files with 74 additions and 60 deletions

View File

@@ -75,17 +75,16 @@ export async function mergeTauriConfig(
// } else {
// fs.rm
// }
let file_path = url.slice(8, url.length);
const url_exists = await fs.stat(file_path)
const url_exists = await fs.stat(url)
.then(() => true)
.catch(() => false);
if (url_exists) {
logger.warn("you input may a local file");
tauriConf.pake.windows[0].url_type = "local";
const file_name = path.basename(file_path);
const file_name = path.basename(url);
// const dir_name = path.dirname(url);
const url_path = path.join("dist/", file_name);
await fs.copyFile(file_path, url_path);
await fs.copyFile(url, url_path);
tauriConf.pake.windows[0].url = file_name;
tauriConf.pake.windows[0].url_type = "local";
} else {