From c394bc13ef2828632a940b623dfcb5bfe3f3e014 Mon Sep 17 00:00:00 2001 From: NextFire Date: Sat, 6 May 2023 00:18:29 +0200 Subject: [PATCH] getMacOSVersion: replace Deno.run with Deno.Command --- music-rpc.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/music-rpc.ts b/music-rpc.ts index f9dd4ec..5ea77b6 100755 --- a/music-rpc.ts +++ b/music-rpc.ts @@ -88,14 +88,10 @@ async function main() { // macOS/JXA functions async function getMacOSVersion(): Promise { - const proc = Deno.run({ - cmd: ["sw_vers", "-productVersion"], - stdout: "piped", - }); - const rawOutput = await proc.output(); - proc.close(); - const output = new TextDecoder().decode(rawOutput); - const version = parseFloat(output.match(/\d+\.\d+/)![0]); + const cmd = new Deno.Command("sw_vers", { args: ["-productVersion"] }); + const output = await cmd.output(); + const decoded = new TextDecoder().decode(output.stdout); + const version = parseFloat(decoded.match(/\d+\.\d+/)![0]); return version; }