mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix: Fix generating tray icons and downloading binaries on windows
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
30f794d66d
commit
289d62caaa
@ -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);
|
||||
|
||||
@ -23,7 +23,7 @@ type Options = typeof options;
|
||||
const assertOption = <Key extends keyof Options>(key: Key): NonNullable<Options[Key]> => {
|
||||
const raw = options[key];
|
||||
|
||||
if (!raw) {
|
||||
if (raw === undefined) {
|
||||
console.error(`missing ${key} option`);
|
||||
process.exit(1);
|
||||
}
|
||||
@ -31,11 +31,21 @@ const assertOption = <Key extends keyof Options>(key: Key): NonNullable<Options[
|
||||
return raw;
|
||||
};
|
||||
|
||||
const joinWithInitCwd = (relativePath: string): string => {
|
||||
const { INIT_CWD } = process.env;
|
||||
|
||||
if (!INIT_CWD) {
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
return path.join(INIT_CWD, relativePath);
|
||||
};
|
||||
|
||||
const size = options["--output-size"] ?? 16;
|
||||
const inputFile = assertOption("--input");
|
||||
const outputFolder = assertOption("--output");
|
||||
const noticeFile = assertOption("--notice-icon");
|
||||
const spinnerFile = assertOption("--spinner-icon");
|
||||
const inputFile = joinWithInitCwd(assertOption("--input"));
|
||||
const outputFolder = joinWithInitCwd(assertOption("--output"));
|
||||
const noticeFile = joinWithInitCwd(assertOption("--notice-icon"));
|
||||
const spinnerFile = joinWithInitCwd(assertOption("--spinner-icon"));
|
||||
|
||||
const getSvgStyling = (colouring: "dark" | "light") => (
|
||||
`
|
||||
|
||||
@ -33,8 +33,8 @@
|
||||
"dev:main": "cross-env NODE_ENV=development webpack --config webpack/main.ts --progress --watch",
|
||||
"dev:renderer": "cross-env NODE_ENV=development ts-node ./webpack/dev-server.ts",
|
||||
"test:integration": "jest -xyz --runInBand --modulePaths=[\"<rootDir>/integration/\"];",
|
||||
"build:tray-icons": "npm run --workspace @k8slens/generate-tray-icons generate -- --output $INIT_CWD/static/build/tray --input $INIT_CWD/../core/src/renderer/components/icon/logo-lens.svg --notice-icon $INIT_CWD/../core/src/renderer/components/icon/notice.svg --spinner-icon $INIT_CWD/../core/src/renderer/components/icon/arrow-spinner.svg",
|
||||
"download:binaries": "npm run --workspace @k8slens/ensure-binaries ensure -- --package $INIT_CWD/package.json --base-dir $INIT_CWD/binaries/client",
|
||||
"build:tray-icons": "npm run --workspace @k8slens/generate-tray-icons generate -- --output static/build/tray --input ../core/src/renderer/components/icon/logo-lens.svg --notice-icon ../core/src/renderer/components/icon/notice.svg --spinner-icon ../core/src/renderer/components/icon/arrow-spinner.svg",
|
||||
"download:binaries": "npm run --workspace @k8slens/ensure-binaries ensure -- --package package.json --base-dir binaries/client",
|
||||
"postinstall": "electron-rebuild"
|
||||
},
|
||||
"config": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user