Files
legado/modules/web/scripts/sync.js
2024-10-03 10:16:25 +08:00

46 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { URL } from "node:url";
import fs from "node:fs";
import process from "node:process";
if (!process.env.GITHUB_ENV) {
console.log("非Github WorkFlows环境取消文件复制");
process.exit();
}
const LEGADO_ASSETS_WEB_VUE_DIR = new URL(
"../../../app/src/main/assets/web/vue",
import.meta.url,
);
const VUE_DIST_DIR = new URL("../dist", import.meta.url);
console.log("> delete", LEGADO_ASSETS_WEB_VUE_DIR.pathname);
// 删除
fs.rm(
LEGADO_ASSETS_WEB_VUE_DIR,
{
force: true,
recursive: true,
},
(error) => {
if (error) console.log(error);
console.log("> mkdir", LEGADO_ASSETS_WEB_VUE_DIR.pathname);
fs.mkdir(LEGADO_ASSETS_WEB_VUE_DIR, (error) => {
if (error) return console.error(error);
console.log("> cp dist files");
fs.cp(
VUE_DIST_DIR,
LEGADO_ASSETS_WEB_VUE_DIR,
{
recursive: true,
},
(error) => {
if (error) {
console.warn("> cp error, you may copy files yourshelf");
throw error;
}
console.log("> cp success");
},
);
});
},
);