1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

fix: skip redefining global __static in tests

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-08-14 12:42:50 +03:00
parent 165788da2d
commit da96776b73
2 changed files with 15 additions and 3 deletions

View File

@ -0,0 +1,12 @@
// Setup variable in global scope (top-level object)
// Global type definition must be added separately to `mocks.d.ts` in form:
// declare const __globalName: any;
export function defineGlobal(propName: string, descriptor: PropertyDescriptor) {
const scope = typeof global !== "undefined" ? global : window;
if (scope.hasOwnProperty(propName)) {
console.info(`Global variable "${propName}" already exists. Skipping.`)
return;
}
Object.defineProperty(scope, propName, descriptor);
}

View File

@ -1,6 +1,7 @@
// App's common configuration for any process (main, renderer, build pipeline, etc.)
import packageInfo from "../../package.json"
import path from "path";
import packageInfo from "../../package.json"
import { defineGlobal } from "./utils/defineGlobal";
export const isMac = process.platform === "darwin"
export const isWindows = process.platform === "win32"
@ -21,8 +22,7 @@ export const htmlTemplate = path.resolve(rendererDir, "template.html");
export const sassCommonVars = path.resolve(rendererDir, "components/vars.scss");
// Special runtime paths
const globScope = typeof global !== "undefined" ? global : window;
Object.defineProperty(globScope, "__static", {
defineGlobal("__static", {
get() {
if (isDevelopment) {
return path.resolve(contextDir, "static");