Skip to content

Commit 5788f8a

Browse files
committed
include stdout and stderr in the output of the tools
1 parent 771005a commit 5788f8a

File tree

6 files changed

+27
-12
lines changed

6 files changed

+27
-12
lines changed

dist/tools/cli.mjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { parseCliArgs, getToolRunner } from './lib.mjs';
1+
import { parseCliArgs, run } from './lib.mjs';
22

33
const { agent, tool, command } = parseCliArgs();
4-
const runner = await getToolRunner(agent, tool);
5-
await runner.run(command);
4+
await run(agent, tool, command);
65
//# sourceMappingURL=cli.mjs.map

dist/tools/cli.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/tools/lib.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { parseArgs } from 'node:util';
2+
import * as process from 'node:process';
23

34
async function getAgent(buildAgent) {
45
const agent = `./${buildAgent}/agent.mjs`;
@@ -22,7 +23,14 @@ function parseCliArgs() {
2223
}
2324
async function run(agent, tool, command) {
2425
const runner = await getToolRunner(agent, tool);
25-
return await runner.run(command);
26+
const { code, stdout, stderr } = await runner.run(command);
27+
if (stdout) {
28+
process.stdout.write(stdout);
29+
}
30+
if (stderr) {
31+
process.stderr.write(stderr);
32+
}
33+
process.exit(code);
2634
}
2735

2836
export { getAgent, getToolRunner, parseCliArgs, run };

dist/tools/lib.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tools/cli.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { getToolRunner, parseCliArgs } from '@lib'
1+
import { parseCliArgs, run } from '@lib'
2+
import { type Commands } from '@tools/gitversion'
23

34
const { agent, tool, command } = parseCliArgs()
4-
const runner = await getToolRunner(agent, tool)
5-
await runner.run(command)
5+
await run(agent, tool, command as Commands)

src/tools/lib.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { parseArgs } from 'node:util'
2+
import * as process from 'node:process'
23

3-
import { type ExecResult, type IBuildAgent } from '@agents/common'
4+
import { type IBuildAgent } from '@agents/common'
45
import { type IRunner } from '@tools/common'
56

67
type CliArgs = {
@@ -32,7 +33,14 @@ export function parseCliArgs(): CliArgs {
3233
}).values as CliArgs
3334
}
3435

35-
export async function run(agent: string, tool: string, command: string): Promise<ExecResult> {
36+
export async function run(agent: string, tool: string, command: string): Promise<void> {
3637
const runner = await getToolRunner(agent, tool)
37-
return await runner.run(command)
38+
const { code, stdout, stderr } = await runner.run(command)
39+
if (stdout) {
40+
process.stdout.write(stdout)
41+
}
42+
if (stderr) {
43+
process.stderr.write(stderr)
44+
}
45+
process.exit(code)
3846
}

0 commit comments

Comments
 (0)