Skip to content

Commit

Permalink
Merge pull request #1341 from arturcic/fix/include-sdtout-stderr
Browse files Browse the repository at this point in the history
Include stdout and stderr
  • Loading branch information
arturcic authored Nov 18, 2024
2 parents 771005a + 5788f8a commit 000e20d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
5 changes: 2 additions & 3 deletions dist/tools/cli.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { parseCliArgs, getToolRunner } from './lib.mjs';
import { parseCliArgs, run } from './lib.mjs';

const { agent, tool, command } = parseCliArgs();
const runner = await getToolRunner(agent, tool);
await runner.run(command);
await run(agent, tool, command);
//# sourceMappingURL=cli.mjs.map
2 changes: 1 addition & 1 deletion dist/tools/cli.mjs.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion dist/tools/lib.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { parseArgs } from 'node:util';
import * as process from 'node:process';

async function getAgent(buildAgent) {
const agent = `./${buildAgent}/agent.mjs`;
Expand All @@ -22,7 +23,14 @@ function parseCliArgs() {
}
async function run(agent, tool, command) {
const runner = await getToolRunner(agent, tool);
return await runner.run(command);
const { code, stdout, stderr } = await runner.run(command);
if (stdout) {
process.stdout.write(stdout);
}
if (stderr) {
process.stderr.write(stderr);
}
process.exit(code);
}

export { getAgent, getToolRunner, parseCliArgs, run };
Expand Down
2 changes: 1 addition & 1 deletion dist/tools/lib.mjs.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/tools/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getToolRunner, parseCliArgs } from '@lib'
import { parseCliArgs, run } from '@lib'
import { type Commands } from '@tools/gitversion'

const { agent, tool, command } = parseCliArgs()
const runner = await getToolRunner(agent, tool)
await runner.run(command)
await run(agent, tool, command as Commands)
14 changes: 11 additions & 3 deletions src/tools/lib.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { parseArgs } from 'node:util'
import * as process from 'node:process'

import { type ExecResult, type IBuildAgent } from '@agents/common'
import { type IBuildAgent } from '@agents/common'
import { type IRunner } from '@tools/common'

type CliArgs = {
Expand Down Expand Up @@ -32,7 +33,14 @@ export function parseCliArgs(): CliArgs {
}).values as CliArgs
}

export async function run(agent: string, tool: string, command: string): Promise<ExecResult> {
export async function run(agent: string, tool: string, command: string): Promise<void> {
const runner = await getToolRunner(agent, tool)
return await runner.run(command)
const { code, stdout, stderr } = await runner.run(command)
if (stdout) {
process.stdout.write(stdout)
}
if (stderr) {
process.stderr.write(stderr)
}
process.exit(code)
}

0 comments on commit 000e20d

Please sign in to comment.