@itcase/config 1.6.66 → 1.6.67

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.
@@ -21,6 +21,13 @@ const WRAPPER = `#!/usr/bin/env sh
21
21
  `
22
22
 
23
23
  function projectRoot() {
24
+ const cwd = process.cwd()
25
+ const marker = `${path.sep}node_modules${path.sep}@itcase${path.sep}config`
26
+ const index = cwd.lastIndexOf(marker)
27
+ if (index !== -1) {
28
+ return cwd.slice(0, index)
29
+ }
30
+
24
31
  const initCwd = process.env.INIT_CWD
25
32
  if (
26
33
  initCwd &&
@@ -30,13 +37,6 @@ function projectRoot() {
30
37
  return initCwd
31
38
  }
32
39
 
33
- const cwd = process.cwd()
34
- const marker = `${path.sep}node_modules${path.sep}@itcase${path.sep}config`
35
- const index = cwd.lastIndexOf(marker)
36
- if (index !== -1) {
37
- return cwd.slice(0, index)
38
- }
39
-
40
40
  return cwd
41
41
  }
42
42
 
@@ -48,24 +48,31 @@ function readHook(huskyDir, name) {
48
48
  }
49
49
  }
50
50
 
51
+ function isOldItcaseHook(text) {
52
+ if (!text || text.includes('_run.sh')) {
53
+ return false
54
+ }
55
+
56
+ return text.includes('GIT_WORKFLOW') && text.includes('/config')
57
+ }
58
+
51
59
  function isItcaseHuskyDir(huskyDir) {
52
- if (fs.existsSync(path.join(huskyDir, '_run.sh'))) {
60
+ if (fs.existsSync(path.join(huskyDir, 'config'))) {
53
61
  return true
54
62
  }
55
63
 
56
- const hookContents = GIT_HOOKS.map((name) => readHook(huskyDir, name))
57
- if (hookContents.some((text) => text?.includes('_run.sh'))) {
64
+ if (fs.existsSync(path.join(huskyDir, '_run.sh'))) {
58
65
  return true
59
66
  }
60
67
 
61
- const hasCustomHooks = hookContents.some(
62
- (text) => text !== null && !text.includes('_run.sh'),
68
+ const hookContents = GIT_HOOKS.map((name) => readHook(huskyDir, name))
69
+ return hookContents.some(
70
+ (text) => text?.includes('_run.sh') || isOldItcaseHook(text),
63
71
  )
64
- if (hasCustomHooks) {
65
- return false
66
- }
72
+ }
67
73
 
68
- return fs.existsSync(path.join(huskyDir, 'config'))
74
+ function shouldWriteWrapper(text) {
75
+ return text === null || text.includes('_run.sh') || isOldItcaseHook(text)
69
76
  }
70
77
 
71
78
  function writeWrapper(huskyDir, name) {
@@ -93,8 +100,7 @@ try {
93
100
  }
94
101
 
95
102
  for (const name of GIT_HOOKS) {
96
- const text = readHook(huskyDir, name)
97
- if (text === null || text.includes('_run.sh')) {
103
+ if (shouldWriteWrapper(readHook(huskyDir, name))) {
98
104
  writeWrapper(huskyDir, name)
99
105
  }
100
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/config",
3
- "version": "1.6.66",
3
+ "version": "1.6.67",
4
4
  "author": "ITCase",
5
5
  "description": "ITCase Config",
6
6
  "engines": {