@peterxiaoyang/superspec 0.1.26 → 0.1.27
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/dist/cli.js +16 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -116,6 +116,18 @@ function isTestMode() {
|
|
|
116
116
|
function testEnv(name) {
|
|
117
117
|
return isTestMode() ? process.env[name] : undefined;
|
|
118
118
|
}
|
|
119
|
+
function runtimePlatform() {
|
|
120
|
+
return testEnv("SUPERSPEC_TEST_PLATFORM") ?? process.platform;
|
|
121
|
+
}
|
|
122
|
+
function windowsAwareCommand(name) {
|
|
123
|
+
return runtimePlatform() === "win32" ? `${name}.cmd` : name;
|
|
124
|
+
}
|
|
125
|
+
function npmCommand() {
|
|
126
|
+
return windowsAwareCommand("npm");
|
|
127
|
+
}
|
|
128
|
+
function superspecCommand() {
|
|
129
|
+
return windowsAwareCommand("superspec");
|
|
130
|
+
}
|
|
119
131
|
function selfUpdateError(phase, err, latest = null) {
|
|
120
132
|
return new SelfUpdateError(phase, commandErrorMessage(err), latest);
|
|
121
133
|
}
|
|
@@ -157,7 +169,7 @@ function npmLatestVersion() {
|
|
|
157
169
|
if (testLatest)
|
|
158
170
|
return testLatest;
|
|
159
171
|
try {
|
|
160
|
-
const output = execFileSync(
|
|
172
|
+
const output = execFileSync(npmCommand(), ["view", PACKAGE_NAME, "version"], { encoding: "utf8" });
|
|
161
173
|
return output.trim().replace(/^"|"$/g, "");
|
|
162
174
|
}
|
|
163
175
|
catch (err) {
|
|
@@ -171,7 +183,7 @@ function installLatestGlobal() {
|
|
|
171
183
|
if (testEnv("SUPERSPEC_TEST_SKIP_GLOBAL_INSTALL") === "1")
|
|
172
184
|
return;
|
|
173
185
|
try {
|
|
174
|
-
execFileSync(
|
|
186
|
+
execFileSync(npmCommand(), ["install", "-g", `${PACKAGE_NAME}@latest`], {
|
|
175
187
|
encoding: "utf8",
|
|
176
188
|
stdio: ["ignore", "pipe", "pipe"],
|
|
177
189
|
});
|
|
@@ -198,7 +210,7 @@ function pathCliVersion() {
|
|
|
198
210
|
throw new Error(`无法解析 superspec --version 输出:${testOutput}`);
|
|
199
211
|
return parsed;
|
|
200
212
|
}
|
|
201
|
-
const output = execFileSync(
|
|
213
|
+
const output = execFileSync(superspecCommand(), ["--version"], {
|
|
202
214
|
encoding: "utf8",
|
|
203
215
|
env: process.env,
|
|
204
216
|
});
|
|
@@ -227,7 +239,7 @@ function rerunUpdatedCli(projectRoot, args) {
|
|
|
227
239
|
if (testOutput)
|
|
228
240
|
return testOutput;
|
|
229
241
|
try {
|
|
230
|
-
return execFileSync(
|
|
242
|
+
return execFileSync(superspecCommand(), args, {
|
|
231
243
|
cwd: projectRoot,
|
|
232
244
|
encoding: "utf8",
|
|
233
245
|
env: process.env,
|