6a-spec-install 1.0.1-dev.2 → 1.0.1-dev.3
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/lib/installer.js +22 -2
- package/package.json +1 -1
package/lib/installer.js
CHANGED
|
@@ -51,11 +51,31 @@ class Installer {
|
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
// 递归删除目录
|
|
55
|
+
removeDir(dirPath) {
|
|
56
|
+
if (fs.existsSync(dirPath)) {
|
|
57
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
58
|
+
for (const entry of entries) {
|
|
59
|
+
const fullPath = path.join(dirPath, entry.name);
|
|
60
|
+
if (entry.isDirectory()) {
|
|
61
|
+
this.removeDir(fullPath);
|
|
62
|
+
} else {
|
|
63
|
+
fs.unlinkSync(fullPath);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
fs.rmdirSync(dirPath);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
54
70
|
// 递归复制目录(完全覆盖模式)
|
|
55
71
|
copyDir(src, dest) {
|
|
56
|
-
|
|
57
|
-
|
|
72
|
+
// 如果目标目录存在,先完全删除(确保完全覆盖)
|
|
73
|
+
if (fs.existsSync(dest)) {
|
|
74
|
+
this.removeDir(dest);
|
|
58
75
|
}
|
|
76
|
+
|
|
77
|
+
// 重新创建目录并复制
|
|
78
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
59
79
|
|
|
60
80
|
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
61
81
|
|