hbuilder-build-move 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/assets/image.png +0 -0
- package/move.js +13 -3
- package/package.json +1 -1
package/README.md
CHANGED
package/assets/image.png
ADDED
|
Binary file
|
package/move.js
CHANGED
|
@@ -3,7 +3,7 @@ const fs = require("fs");
|
|
|
3
3
|
const fsPromise = require("fs/promises");
|
|
4
4
|
const childProcess = require("child_process");
|
|
5
5
|
|
|
6
|
-
const {
|
|
6
|
+
const { spawnSync } = childProcess;
|
|
7
7
|
|
|
8
8
|
async function main(src, dest, commitInfo) {
|
|
9
9
|
const getProjectRoot = (startPath = __dirname) => {
|
|
@@ -40,6 +40,17 @@ async function main(src, dest, commitInfo) {
|
|
|
40
40
|
if (!fs.existsSync(targetDir)) {
|
|
41
41
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
42
42
|
console.log(dest + " 目录创建完成");
|
|
43
|
+
} else {
|
|
44
|
+
// 删除目标目录下的文件
|
|
45
|
+
const result = spawnSync("rm", ["-rf", targetDir]);
|
|
46
|
+
console.log("result: ", result);
|
|
47
|
+
|
|
48
|
+
if (result.status !== 0) {
|
|
49
|
+
handleError("❌ 删除旧文件失败");
|
|
50
|
+
process.exit(1); // 终止后续命令
|
|
51
|
+
} else {
|
|
52
|
+
console.log("🎉 删除旧文件成功");
|
|
53
|
+
}
|
|
43
54
|
}
|
|
44
55
|
console.log("源目录 :>> ", path.join(projectRoot, src));
|
|
45
56
|
console.log("目标目录 :>> ", targetDir);
|
|
@@ -84,8 +95,7 @@ async function main(src, dest, commitInfo) {
|
|
|
84
95
|
for (const command of gitCommands) {
|
|
85
96
|
const result = spawnSync(command.cmd, command.args, { stdio: "inherit" });
|
|
86
97
|
if (result.status !== 0) {
|
|
87
|
-
|
|
88
|
-
handleError(`命令 ${command.cmd} 执行失败`);
|
|
98
|
+
handleError(`❌ 命令 ${command.cmd} 执行失败`);
|
|
89
99
|
process.exit(1); // 终止后续命令
|
|
90
100
|
}
|
|
91
101
|
}
|