@ruan-cat/vercel-deploy-tool 0.6.1 → 0.6.2
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 +1 -1
- package/src/index.ts +30 -10
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -168,8 +168,17 @@ function getTargetCWDCommandArgument(deployTarget: DeployTarget) {
|
|
|
168
168
|
* 封装 spawnSync 函数
|
|
169
169
|
* @version 2
|
|
170
170
|
*/
|
|
171
|
-
function generateExeca(execaSimpleParams: {
|
|
172
|
-
|
|
171
|
+
function generateExeca(execaSimpleParams: {
|
|
172
|
+
command: string;
|
|
173
|
+
parameters: string[];
|
|
174
|
+
/**
|
|
175
|
+
* 是否流式输出内容
|
|
176
|
+
* @description 默认输出的命令数据全部以流式的方式输出
|
|
177
|
+
* @default true
|
|
178
|
+
*/
|
|
179
|
+
isFlow?: boolean;
|
|
180
|
+
}) {
|
|
181
|
+
const { command, parameters, isFlow = true } = execaSimpleParams;
|
|
173
182
|
|
|
174
183
|
if (config?.isShowCommand) {
|
|
175
184
|
const coloredCommand = gradient(["rgb(0, 153, 247)", "rgb(241, 23, 18)"])(`${command} ${parameters.join(" ")}`);
|
|
@@ -177,7 +186,22 @@ function generateExeca(execaSimpleParams: { command: string; parameters: string[
|
|
|
177
186
|
}
|
|
178
187
|
|
|
179
188
|
return generateSimpleAsyncTask(() => {
|
|
180
|
-
const result = spawnSync(command, parameters, {
|
|
189
|
+
const result = spawnSync(command, parameters, {
|
|
190
|
+
/**
|
|
191
|
+
* 是否流式输出?
|
|
192
|
+
* 是流式输出就是继承父进程的流式输出
|
|
193
|
+
* 否则就使用默认值
|
|
194
|
+
* @see https://nodejs.org/api/child_process.html#optionsstdio
|
|
195
|
+
*/
|
|
196
|
+
stdio: isFlow ? "inherit" : "pipe",
|
|
197
|
+
shell: true,
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// 如果不是流式输出 就直接返回返回值即可
|
|
201
|
+
if (!isFlow) {
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
|
|
181
205
|
if (result.error) {
|
|
182
206
|
throw result.error;
|
|
183
207
|
}
|
|
@@ -383,6 +407,8 @@ function generateDeployTask(deployTarget: DeployTarget) {
|
|
|
383
407
|
getTargetCWDCommandArgument(deployTarget),
|
|
384
408
|
getVercelTokenCommandArgument(),
|
|
385
409
|
),
|
|
410
|
+
// 部署任务不需要流式输出
|
|
411
|
+
isFlow: false,
|
|
386
412
|
});
|
|
387
413
|
}
|
|
388
414
|
|
|
@@ -487,12 +513,8 @@ async function main() {
|
|
|
487
513
|
parameters: [],
|
|
488
514
|
});
|
|
489
515
|
consola.start(` 开始用户命令任务 `);
|
|
490
|
-
|
|
491
|
-
process.stdout.write(child.stdout);
|
|
492
|
-
process.stderr.write(child.stderr);
|
|
493
|
-
// consola.success(` 完成用户命令任务 ${code} `);
|
|
516
|
+
await userCommand();
|
|
494
517
|
consola.success(` 完成用户命令任务 `);
|
|
495
|
-
// consola.box(stdout);
|
|
496
518
|
});
|
|
497
519
|
}),
|
|
498
520
|
},
|
|
@@ -531,7 +553,6 @@ async function main() {
|
|
|
531
553
|
if (error) {
|
|
532
554
|
consola.error(" 部署失败了 \n");
|
|
533
555
|
consola.error(error);
|
|
534
|
-
process.stderr.write(stderr);
|
|
535
556
|
return;
|
|
536
557
|
}
|
|
537
558
|
|
|
@@ -540,7 +561,6 @@ async function main() {
|
|
|
540
561
|
consola.box(vercelUrl);
|
|
541
562
|
|
|
542
563
|
consola.success(` 部署任务输出如下: \n`);
|
|
543
|
-
process.stdout.write(stdout);
|
|
544
564
|
console.log(`\n`);
|
|
545
565
|
|
|
546
566
|
return vercelUrl;
|