@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 CHANGED
@@ -1,3 +1 @@
1
- # dev
2
-
3
- 开发环境依赖包
1
+ # 自动生成
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/dev",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "开发环境依赖包",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -8,16 +8,36 @@ const __dirname = path.dirname(__filename)
8
8
 
9
9
  const cwd = process.cwd().split('node_modules')[0]
10
10
 
11
- fs.readdirSync(path.resolve(__dirname, './tmp'), { withFileTypes: true }).forEach(item => {
12
- const sourcePath = path.resolve(item.path, item.name)
13
- const filePath = path.resolve(cwd, item.name)
14
- if (fs.existsSync(filePath)) return
11
+ function copyDirectorySync(source, target) {
12
+ // 创建目标目录(如果不存在)
13
+ if (!fs.existsSync(target)) {
14
+ fs.mkdirSync(target)
15
+ }
15
16
 
16
- fs.createReadStream(sourcePath).pipe(fs.createWriteStream(filePath))
17
- })
17
+ // 获取源目录下的所有文件和子目录
18
+ const files = fs.readdirSync(source, { withFileTypes: true })
18
19
 
19
- // fs.writeFileSync(path.resolve(cmd, 'log.text'), `${sourcePath}}\n`, {
20
- // flag: 'a',
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 })
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx commitlint --edit $1
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx lint-staged