-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use Child-Shell #153
Comments
Here is a working example of how you can use node-powershell or child-shell: import { exit } from 'node:process';
import { PowerShell } from 'node-powershell';
(async () => {
try {
const output = await PowerShell.$$`echo "hello from PowerShell"`({
executableOptions: {
'-ExecutionPolicy': 'Bypass',
'-NoProfile': true,
},
});
if (!output.hadErrors) {
console.log(output.stdout.toString());
}
else {
console.error(output.stderr.toString());
}
}
catch (error) {
console.error(error);
exit(1);
}
exit(0);
})(); |
I'm trying this but my stdout is undefined however the debug is showing output and there are no errors. let result = await ps.invoke(command)
if (!result.hadErrors) {
console.log(result.stdout?.toString())
} |
That is the syntax of the previous major version. The current one has changed a lot and there's hardly any info about it in the readme, hence the title of the issue and my answer. |
I'm trying the following const result = await Bash.$$`echo "hello from Bash"`({
debug: true,
invocationTimeout: 1000,
disposeTimeout: 3000,
throwOnInvocationError: false,
});
if (!result.hadErrors) {
console.log(result?.stdout?.toString());
}
else {
console.error(result?.stderr?.toString());
} and get this output
This sort of works, except for the random strings (N8yLS6keUkmuJ97u) in the output, however when I try run
and lastly when I run
All these commands work in a normal Bash and Powershell shell so not entirely sure whats happening here |
No description provided.
The text was updated successfully, but these errors were encountered: