sync.js 971 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { URL } from "node:url";
  2. import fs from "node:fs";
  3. const LEGADO_ASSETS_WEB_VUE_DIR = new URL(
  4. "../../../app/src/main/assets/web/vue",
  5. import.meta.url
  6. );
  7. const VUE_DIST_DIR = new URL("../dist", import.meta.url);
  8. console.log("> delete", LEGADO_ASSETS_WEB_VUE_DIR.pathname);
  9. // 删除
  10. fs.rm(
  11. LEGADO_ASSETS_WEB_VUE_DIR,
  12. {
  13. force: true,
  14. recursive: true,
  15. },
  16. (error) => {
  17. if (error) console.log(error);
  18. console.log("> mkdir", LEGADO_ASSETS_WEB_VUE_DIR.pathname);
  19. fs.mkdir(LEGADO_ASSETS_WEB_VUE_DIR, (error) => {
  20. if (error) return console.error(error);
  21. console.log("> cp dist files");
  22. fs.cp(
  23. VUE_DIST_DIR,
  24. LEGADO_ASSETS_WEB_VUE_DIR,
  25. {
  26. recursive: true,
  27. },
  28. (error) => {
  29. if (error) {
  30. console.warn("> cp error, you may copy files yourshelf");
  31. throw error;
  32. }
  33. console.log("> cp success");
  34. }
  35. );
  36. });
  37. }
  38. );