Open nikitavoloboev opened 1 year ago
repo where I am using cmd-ts: https://github.com/nikitavoloboev/gitty
code I want to make work is here
What’s the console output then?
It's empty.
Very suspicious. I hope I will have some time to take a look. You are more than welcome to fork and add a test.
I think i might have a similar problem using bun shell instead of "execa"
running
const pwd= await $`pwd`.text()
console.log(pwd)
inside a "handler" will simply terminate the script and not output anything
A workaround is using a custom script.
function execShellCommand(cmd:string):Promise<string> {
const exec = require('child_process').exec;
return new Promise((resolve, reject) => {
exec(cmd, (error:unknown, stdout:string, stderr:string) => {
if (error) {
console.warn(error);
}
resolve(stdout? stdout : stderr);
});
});
}
const pwd=await execShellCommand(`pwd`)
console.log(pwd)
I tried doing this:
But then if you try run it, you won't get
echo unicorns
as output.If you run below code outside the handler:
It works as expected. Not sure why that happens or how to fix.