BREAKING(unstable): Improve Deno.spawn() stdio API (#14919)

- "SpawnOutput" extends "ChildStatus" instead of composing it
- "SpawnOutput::stdout", "SpawnOutput::stderr", "Child::stdin", 
"Child::stdout" and "Child::stderr" are no longer optional, instead 
made them getters that throw at runtime if that stream wasn't set 
to "piped". 
- Remove the complicated "<T extends SpawnOptions = SpawnOptions>" 
which we currently need to give proper type hints for the availability of 
these fields. Their typings for these would get increasingly complex 
if it became dependent on more options (e.g. "SpawnOptions::pty" 
which if set should make the stdio streams unavailable)
This commit is contained in:
Nayeem Rahman 2022-07-18 14:16:12 +01:00 committed by GitHub
parent 0f6b455c96
commit 45c49034a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 176 additions and 149 deletions

View file

@ -185,14 +185,14 @@ Deno.test(
permissions: { run: true, read: true },
},
async function canExitWhileListeningToSignal() {
const { status } = await Deno.spawn(Deno.execPath(), {
const { code } = await Deno.spawn(Deno.execPath(), {
args: [
"eval",
"--unstable",
"Deno.addSignalListener('SIGINT', () => {})",
],
});
assertEquals(status.code, 0);
assertEquals(code, 0);
},
);