Skip to content

Commit

Permalink
fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeOShannessy committed Jun 23, 2024
1 parent 2bd3749 commit 24a11ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
37 changes: 11 additions & 26 deletions open.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// deno-lint-ignore-file require-await
import { join } from "jsr:@std/[email protected]";
const { os } = Deno.build;

Expand Down Expand Up @@ -38,7 +39,8 @@ const hasWslEnv = async () => {
}

try {
let build = Deno.readTextFileSync("/proc/version").toString().toLowerCase();
const build = Deno.readTextFileSync("/proc/version").toString()
.toLowerCase();

return build.includes("microsoft") ? !(await isDocker()) : false;
} catch (_) {
Expand Down Expand Up @@ -116,7 +118,7 @@ const localXdgOpenPath = join(getDir(import.meta.url), "xdg-open");
export async function open(
target: string,
options?: OpenOptions,
): Promise<Deno.Process> {
): Promise<Deno.ChildProcess> {
if (typeof target !== "string") {
throw new TypeError("Expected a target");
}
Expand Down Expand Up @@ -175,7 +177,7 @@ export async function open(
cliArguments.push(...appArguments);
}
} else {
let wsl = await isWsl();
const wsl = await isWsl();
if (options.app) {
command = options.app;
} else if (wsl) {
Expand All @@ -186,7 +188,7 @@ export async function open(
getDir(import.meta.url) === "/";

// Check if local `xdg-open` exists and is executable.
let exeLocalXdgOpen = await isFile(localXdgOpenPath);
const exeLocalXdgOpen = await isFile(localXdgOpenPath);

const useSystemXdgOpen = isBundled || !exeLocalXdgOpen;
command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
Expand All @@ -203,34 +205,17 @@ export async function open(
cliArguments.push("--args", ...appArguments);
}

/* Options for the spawned process */
const runOptions: Deno.RunOptions = {
cmd: [command, ...cliArguments],
const cmd = new Deno.Command(command, {
args: cliArguments,
stdin: "piped",
stderr: "piped",
stdout: "piped",
};
});

const subprocess = Deno.run(runOptions);
await subprocess.status();
const subprocess = cmd.spawn();
// await subprocess.status();

// command: open /Applications/Google\ Chrome.app {url}
if (options.wait) {
return new Promise(async (resolve, reject) => {
const status = await subprocess.status();
const err = await subprocess.stderrOutput();
if (err) {
if (err.length !== 0) reject(new TextDecoder().decode(err));
}

if (status.code && status.code > 0) {
reject(new Error(`Exited with code ${status.code}`));
return;
}

resolve(subprocess);
});
}

return subprocess;
}
3 changes: 1 addition & 2 deletions plot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export async function plotDv(
dash?: number[];
})[],
title: string,
_plotConfig?: {},
extras?: {
sprinklerTime?: number;
detectorTime?: number;
Expand Down Expand Up @@ -435,7 +434,7 @@ export function plotHRRDV(
extras.door = spec?.door;
extras.sprinklerTime = spec?.sprinklerTime;
extras.detectorTime = spec?.detectorTime;
return plotDv(plotPath, vecs, name, {}, extras);
return plotDv(plotPath, vecs, name, extras);
}

// Weighted moving average
Expand Down

0 comments on commit 24a11ca

Please sign in to comment.