fix: Fix generating tray icons and downloading binaries on windows

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2023-04-14 14:42:00 -04:00
1 parent 30f794d66d
commit 289d62caaa
3 files changed
+40 -15

No files matched your search

+23 -8
View File
@@ -23,16 +23,31 @@ const options = arg({
"--base-dir": String,
});
const pathToPackage = options["--package"];
const pathToBaseDir = options["--base-dir"];
type Options = typeof options;
if (typeof pathToPackage !== "string") {
throw new Error("--package is required");
}
const assertOption = <Key extends keyof Options>(key: Key): NonNullable<Options[Key]> => {
const raw = options[key];
if (typeof pathToBaseDir !== "string") {
throw new Error("--base-dir is required");
}
if (raw === undefined) {
console.error(`missing ${key} option`);
process.exit(1);
}
return raw;
};
const joinWithInitCwd = (relativePath: string): string => {
const { INIT_CWD } = process.env;
if (!INIT_CWD) {
return relativePath;
}
return path.join(INIT_CWD, relativePath);
};
const pathToPackage = joinWithInitCwd(assertOption("--package"));
const pathToBaseDir = joinWithInitCwd(assertOption("--base-dir"));
function setTimeoutFor(controller: AbortController, timeout: number): void {
const handle = setTimeout(() => controller.abort(), timeout);