fix(ci): use Deno.Command instead of Deno.run to fix Deno fmt error (#70)

main
hasefumi23 2023-05-29 22:44:58 +09:00 committed by GitHub
parent e78d3cd1cf
commit feb486e775
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 17 deletions

View File

@ -9,22 +9,19 @@ if (import.meta.main) {
"x86_64-apple-darwin", "x86_64-apple-darwin",
"aarch64-apple-darwin", "aarch64-apple-darwin",
]; ];
const rustInfo = new TextDecoder().decode( const rustInfo = await (new Deno.Command("rustc", {
await Deno.run({ args: ["-Vv"],
cmd: ["rustc", "-Vv"], })).output();
stdout: "piped", const target =
}).output(), /host: (\S+)/g.exec(new TextDecoder().decode(rustInfo.stdout))?.[1] ?? "?";
);
const target = /host: (\S+)/g.exec(rustInfo)?.[1] ?? "?";
if (!TARGETS.includes(target)) { if (!TARGETS.includes(target)) {
console.error(`Unsupported target: ${target}`); console.error(`Unsupported target: ${target}`);
Deno.exit(1); Deno.exit(1);
} }
const p = Deno.run({ const p = new Deno.Command("deno", {
cmd: [ args: [
"deno",
"compile", "compile",
"--target", "--target",
target, target,
@ -35,7 +32,7 @@ if (import.meta.main) {
], ],
cwd: __dirname, cwd: __dirname,
}); });
const status = await p.status(); const status = await p.output();
if (!status.success) { if (!status.success) {
console.error( console.error(
"Failed to run deno compile for target", "Failed to run deno compile for target",
@ -50,18 +47,21 @@ if (import.meta.main) {
Deno.build.os === "windows" ? ".exe" : "" Deno.build.os === "windows" ? ".exe" : ""
}`; }`;
console.log("Test the binary"); console.log("Test the binary");
const s3si = Deno.run({ const s3si = new Deno.Command(binPath, {
cmd: [binPath],
stdin: "piped", stdin: "piped",
stdout: "piped", stdout: "piped",
}); }).spawn();
await s3si.stdin?.write( const s3siWriter = s3si.stdin.getWriter();
await s3siWriter.write(
new TextEncoder().encode( new TextEncoder().encode(
'{"jsonrpc":"2.0","method":"hello","params":[],"id":1}\n', '{"jsonrpc":"2.0","method":"hello","params":[],"id":1}\n',
), ),
); );
s3si.stdin?.close();
const output = new TextDecoder().decode(await s3si.output()); const output = new TextDecoder().decode(
(await s3si.stdout.getReader().read()).value,
);
await s3siWriter.close();
assertEquals( assertEquals(
output, output,