Replies: 1 comment 1 reply
-
I've also tried this other way, but I got the same result. import chalk from 'chalk'
import { stripIndents } from 'common-tags'
export const spreadCommand = async (cmd: string, args: string[]) => {
const proc = Bun.spawn([cmd, ...args],
{
stdin: 'inherit',
stdout: 'inherit',
stderr: 'pipe',
shell: true
});
const errors: string = await Bun.readableStreamToText(proc.stderr);
if (errors) {
console.error(stripIndents`
${chalk.red.bold('Error')}:
${errors}
`)
proc.kill(1)
}
return proc.exitCode
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm been trying to migrate a cli utility from
node
tobun
. It's a tool that receives a command with arguments and run it usingspawn
.Original method with node:
Method migrated to Bun:
I've tested it. When the command exist (like 'bun install') all works fine, but when the commant doesn't exist it will show a bun error instead of showing the command error.
The code never go inside the
onError
, intead the function fails:Same test with previous method written in node show the expected error in the terminal:
Docs
Beta Was this translation helpful? Give feedback.
All reactions