-
Notifications
You must be signed in to change notification settings - Fork 622
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
feat(node): Basic support for child_process.spawn #785
Conversation
exitCode = code; | ||
}); | ||
await promise; | ||
assertStrictEquals(exitCode, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@uki00a What do you think is the remaining task for the first pass? |
@kt3k I'm still having one problem and not sure yet if that problem is caused by this PR's code or by the What is the problem?There is a import { spawn } from "./node/child_process.ts"
const deno = spawn("deno", ["--version"]);
let out = "";
deno.stdout!.on("data", (chunk) => {
out += chunk;
});
deno.stderr!.on("data", (err) => console.error(err));
deno.on("exit", () => {
console.log(out);
}); When I run this file, it works as intended: $ deno run -A --unstable test.ts
deno 1.8.3 (release, x86_64-unknown-linux-gnu)
v8 9.0.257.3
typescript 4.2.2 Then, change the import { spawn } from "./node/child_process.ts"
const git = spawn("git", ["--version"]);
let out = "";
git.stdout!.on("data", (chunk) => {
out += chunk;
});
git.stderr!.on("data", (err) => console.error(err));
git.on("exit", () => {
console.log(out);
}); When I run the $ deno run -A --unstable test.ts
Uncaught Interrupted: operation canceled
Uncaught Interrupted: operation canceled |
The problem causing the "operation canceled" error has been resolved by 9e38473. However, tests for the canary build seem to be failing... 🤔🧐 error: TS2322 [ERROR]: Type '{ transport: string; hostname: string; port: number; }' is not assignable to type 'Addr'.
Object literal may only specify known properties, and 'hostname' does not exist in type 'Addr'.
hostname: "",
~~~~~~~~~~~~
at file:///Users/runner/work/deno_std/deno_std/http/_mock_conn.ts:8:7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@uki00a Nice work! Thanks!
LGTM
Thanks! |
Summary
This PR adds basic support for
child_process.spawn
based on theDeno.run
API.Related to denoland/deno#5376
Limitation
Currently, support for the
shell
option in Windows is quite limited due to escaping issues. For more details, see the following issues: