refactor: use spawn API across codebase (#14414)

This commit is contained in:
Leo Kettmeir 2022-05-18 22:00:11 +02:00 committed by GitHub
parent 5ad8919d64
commit 4e1ca1d178
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 266 additions and 327 deletions

View file

@ -1019,20 +1019,14 @@ function createHttpsListener(port: number): Deno.Listener {
}
async function curl(url: string): Promise<string> {
const curl = Deno.run({
cmd: ["curl", "--insecure", url],
stdout: "piped",
const { status, stdout } = await Deno.spawn("curl", {
args: ["--insecure", url],
});
try {
const [status, output] = await Promise.all([curl.status(), curl.output()]);
if (!status.success) {
throw new Error(`curl ${url} failed: ${status.code}`);
}
return new TextDecoder().decode(output);
} finally {
curl.close();
if (!status.success) {
throw new Error(`curl ${url} failed: ${status.code}`);
}
return new TextDecoder().decode(stdout);
}
Deno.test(