@lntvow/dev 0.0.16 → 0.1.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/dev",
3
- "version": "0.0.16",
3
+ "version": "0.1.0",
4
4
  "description": "开发环境依赖包",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs'
2
2
  import path from 'node:path'
3
3
  import { fileURLToPath } from 'node:url'
4
- import { exec } from 'node:child_process'
4
+ import { execSync } from 'node:child_process'
5
5
 
6
6
  const __filename = fileURLToPath(import.meta.url)
7
7
  const __dirname = path.dirname(__filename)
@@ -38,6 +38,23 @@ function copyDirectorySync(source, target) {
38
38
  })
39
39
  }
40
40
 
41
+ // 复制模板文件
41
42
  copyDirectorySync(path.resolve(__dirname, './tmp'), cwd)
42
43
 
43
- exec('npx husky install', { cwd })
44
+ // 初始化 husky
45
+ execSync('npx husky install', { cwd })
46
+
47
+ // 写入 lint-staged 配置
48
+ setTimeout(() => {
49
+ const packageJson = fs.readFileSync(path.resolve(cwd, './package.json'), 'utf8')
50
+ const packageJsonObj = JSON.parse(packageJson)
51
+
52
+ if (!packageJsonObj['lint-staged']) {
53
+ packageJsonObj['lint-staged'] = {
54
+ '*.{js,jsx,ts,tsx,vue}': ['eslint --fix'],
55
+ '*.{json,css,scss,md}': ['prettier --write'],
56
+ }
57
+ fs.writeFileSync(path.resolve(cwd, './package.json'), JSON.stringify(packageJsonObj, null, 2))
58
+ }
59
+ console.log('lint-staged 配置写入成功')
60
+ }, 1000)