@lntvow/dev 0.0.15 → 0.0.16
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 +1 -3
- package/package.json +1 -1
- package/script/postinstall.js +29 -9
- package/script/tmp/.husky/commit-msg +4 -0
- package/script/tmp/.husky/pre-commit +4 -0
package/README.md
CHANGED
package/package.json
CHANGED
package/script/postinstall.js
CHANGED
|
@@ -8,16 +8,36 @@ const __dirname = path.dirname(__filename)
|
|
|
8
8
|
|
|
9
9
|
const cwd = process.cwd().split('node_modules')[0]
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
function copyDirectorySync(source, target) {
|
|
12
|
+
// 创建目标目录(如果不存在)
|
|
13
|
+
if (!fs.existsSync(target)) {
|
|
14
|
+
fs.mkdirSync(target)
|
|
15
|
+
}
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
})
|
|
17
|
+
// 获取源目录下的所有文件和子目录
|
|
18
|
+
const files = fs.readdirSync(source, { withFileTypes: true })
|
|
18
19
|
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
// 遍历并复制文件和子目录
|
|
21
|
+
files.forEach(file => {
|
|
22
|
+
const sourcePath = path.resolve(source, file.name)
|
|
23
|
+
const filePath = path.resolve(target, file.name)
|
|
24
|
+
|
|
25
|
+
if (file.isDirectory()) {
|
|
26
|
+
// 如果是子目录,递归复制
|
|
27
|
+
console.log(`发现目录: ${sourcePath}`)
|
|
28
|
+
copyDirectorySync(sourcePath, filePath)
|
|
29
|
+
} else {
|
|
30
|
+
if (fs.existsSync(filePath)) {
|
|
31
|
+
return console.log(`文件存在跳过: ${sourcePath}`)
|
|
32
|
+
}
|
|
33
|
+
// 如果是文件,使用流复制
|
|
34
|
+
fs.createReadStream(sourcePath).pipe(fs.createWriteStream(filePath))
|
|
35
|
+
|
|
36
|
+
console.log(`文件复制成功: ${sourcePath}`)
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
copyDirectorySync(path.resolve(__dirname, './tmp'), cwd)
|
|
22
42
|
|
|
23
43
|
exec('npx husky install', { cwd })
|