mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
refactor: use spawn API across codebase (#14414)
This commit is contained in:
parent
5ad8919d64
commit
4e1ca1d178
25 changed files with 266 additions and 327 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue