@yangrunchi/a_6 1.0.7 → 1.0.8
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/Tools/svn-utils.js +27 -2
- package/package.json +1 -1
package/Tools/svn-utils.js
CHANGED
|
@@ -52,10 +52,23 @@ function runCommand(svnPath, description) {
|
|
|
52
52
|
projectRoot = parent;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
// 如果从 svnPath 向上找不到 .svn,尝试用 M2_PROJECT_ROOT 环境变量
|
|
56
|
+
if (!projectRoot || !fs.existsSync(path.join(projectRoot, '.svn'))) {
|
|
57
|
+
if (process.env.M2_PROJECT_ROOT) {
|
|
58
|
+
projectRoot = process.env.M2_PROJECT_ROOT;
|
|
59
|
+
// 从项目根目录向上查找 .svn(.svn 通常在项目根目录或上级)
|
|
60
|
+
while (projectRoot && !fs.existsSync(path.join(projectRoot, '.svn'))) {
|
|
61
|
+
const parent = path.dirname(projectRoot);
|
|
62
|
+
if (parent === projectRoot) break;
|
|
63
|
+
projectRoot = parent;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
55
68
|
const result = spawnSync('svn', ['update', svnPath], {
|
|
56
69
|
encoding: 'utf8',
|
|
57
70
|
stdio: 'inherit',
|
|
58
|
-
cwd: projectRoot ||
|
|
71
|
+
cwd: projectRoot || process.cwd()
|
|
59
72
|
});
|
|
60
73
|
|
|
61
74
|
if (result.status === 0) {
|
|
@@ -88,6 +101,18 @@ function runCommit(filePaths, description) {
|
|
|
88
101
|
if (parent === projectRoot) break;
|
|
89
102
|
projectRoot = parent;
|
|
90
103
|
}
|
|
104
|
+
|
|
105
|
+
// 如果从文件路径向上找不到 .svn,尝试用 M2_PROJECT_ROOT 环境变量
|
|
106
|
+
if (!projectRoot || !fs.existsSync(path.join(projectRoot, '.svn'))) {
|
|
107
|
+
if (process.env.M2_PROJECT_ROOT) {
|
|
108
|
+
projectRoot = process.env.M2_PROJECT_ROOT;
|
|
109
|
+
while (projectRoot && !fs.existsSync(path.join(projectRoot, '.svn'))) {
|
|
110
|
+
const parent = path.dirname(projectRoot);
|
|
111
|
+
if (parent === projectRoot) break;
|
|
112
|
+
projectRoot = parent;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
91
116
|
|
|
92
117
|
const args = ['commit', ...paths, '-m', description];
|
|
93
118
|
|
|
@@ -95,7 +120,7 @@ function runCommit(filePaths, description) {
|
|
|
95
120
|
encoding: 'buffer',
|
|
96
121
|
env: { ...process.env, LANG: 'zh_CN.UTF-8' },
|
|
97
122
|
stdio: 'inherit',
|
|
98
|
-
cwd: projectRoot ||
|
|
123
|
+
cwd: projectRoot || process.cwd()
|
|
99
124
|
});
|
|
100
125
|
|
|
101
126
|
if (result.status === 0) {
|