-
Notifications
You must be signed in to change notification settings - Fork 1
/
webviewd.ts
44 lines (34 loc) · 1.11 KB
/
webviewd.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env deno run --allow-env --allow-run
import { join } from "https://deno.land/[email protected]/path/mod.ts";
import * as log from "https://deno.land/[email protected]/log/mod.ts";
const __dirname = new URL(".", import.meta.url).pathname;
var binaryPath;
if (Deno.build.os === "windows") {
binaryPath = join(__dirname, "bin", "webview-win32-amd64.exe").slice(1);
} else if (Deno.build.os === "darwin") {
binaryPath = join(__dirname, "bin", "webview-darwin-amd64");
} else if (Deno.build.os === "linux") {
binaryPath = join(__dirname, "bin", "webview-linux-amd64");
} else {
log.critical("⚠ Unsupported platform: " + Deno.build.os);
}
if (!binaryPath) {
Deno.exit(0);
}
// create webview
const webview = Deno.run({
cmd: [binaryPath, ...Deno.args],
stdout: "piped",
stderr: "piped",
});
// await its completion
const { code } = await webview.status();
const rawOutput = await webview.output();
const rawError = await webview.stderrOutput();
if (code === 0) {
await Deno.stdout.write(rawOutput);
} else {
const errorString = new TextDecoder().decode(rawError);
console.log(errorString);
}
Deno.exit(code);