MCPcopy
hub / github.com/midwayjs/midway / runCommand

Method runCommand

packages/commander/src/framework.ts:64–72  ·  view source on GitHub ↗

* 适用于测试或编程式触发命令的场景。 * * 与 run() 不同,这里不会读取 process.argv,而是解析传入的 args, * 从而避免测试环境(Jest/Node)对命令行参数的污染。

(...args: string[])

Source from the content-addressed store, hash-verified

62 * 从而避免测试环境(Jest/Node)对命令行参数的污染。
63 */
64 public async runCommand(...args: string[]) {
65 this.loadCommands();
66 try {
67 return await this.program.parseAsync(args, { from: 'user' });
68 } catch (error) {
69 this.handleError(error, false);
70 throw error;
71 }
72 }
73
74 private handleError(error: unknown, useDefault: boolean) {
75 const err = error instanceof Error ? error : new Error(String(error));

Callers 2

index.test.tsFile · 0.80
index.test.tsFile · 0.80

Calls 2

loadCommandsMethod · 0.95
handleErrorMethod · 0.95

Tested by

no test coverage detected