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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # HBuilderX 工具打包 H5 资源后,将资源移动到指定目录
2
2
 
3
- ```
3
+ ```shell
4
4
  hbm build_commit_info
5
+ # 目标目录默认值是 build/h5,可以自定义,例如:
6
+ hbm build_commit_info -t dist
5
7
  ```
8
+
9
+ ![image](assets/image.png)
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 { spawn, spawnSync } = childProcess;
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
- console.error(`命令 ${command.cmd} 执行失败,退出码: ${result.status}`);
88
- handleError(`命令 ${command.cmd} 执行失败`);
98
+ handleError(`❌ 命令 ${command.cmd} 执行失败`);
89
99
  process.exit(1); // 终止后续命令
90
100
  }
91
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hbuilder-build-move",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "将打包好的资源移动到项目指定的目录下",
5
5
  "keywords": [
6
6
  "Hbuilder",