Skip to content

Commit

Permalink
fix: Fixed IS_NODE_ENV support detect electron environment and close #47
Browse files Browse the repository at this point in the history
  • Loading branch information
myxvisual committed May 22, 2018
1 parent dba56db commit f3faeda
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/common/electron/IS_ELECTRON_ENV.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const userAgent = navigator.userAgent.toLowerCase();
const isElectronEnv = userAgent.includes(" electron/");

export default isElectronEnv;
4 changes: 3 additions & 1 deletion src/common/nodeJS/IS_NODE_ENV.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const IS_NODE_ENV = global && global.process;
import IS_ELECTRON_ENV from "../electron/IS_ELECTRON_ENV";

const IS_NODE_ENV = global && global.process && !IS_ELECTRON_ENV;

export default IS_NODE_ENV;
1 change: 1 addition & 0 deletions src/styles/StyleManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as createHash from "murmurhash-js/murmurhash3_gc";
import IS_NODE_ENV from "../common/nodeJS/IS_NODE_ENV";
import isUnitlessNumber from "../common/react/isUnitlessNumber";
import isElectronEnv from "../common/electron/IS_ELECTRON_ENV";

export const replace2Dashes = (key: string) => key.replace(/[A-Z]/g, $1 => `-${$1.toLowerCase()}`);
export const getStyleValue = (key: string, value: string) => ((typeof value === "number" && !(isUnitlessNumber as any)[key]) ? `${value}px` : value);
Expand Down

0 comments on commit f3faeda

Please sign in to comment.