Skip to content

Commit b8aba2e

Browse files
committed
Add electron environment check, fix #376
1 parent b603d42 commit b8aba2e

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

package-lock.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"bmp-js": "^0.1.0",
6161
"file-type": "^12.4.1",
6262
"idb-keyval": "^3.2.0",
63+
"is-electron": "^2.2.0",
6364
"is-url": "1.2.2",
6465
"node-fetch": "^2.6.0",
6566
"opencollective-postinstall": "^2.0.2",

src/utils/getEnvironment.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
const isElectron = require('is-electron');
2+
13
module.exports = (key) => {
24
const env = {};
35

4-
if (typeof window === 'object') {
6+
if (isElectron()) {
7+
env.type = 'electron';
8+
} else if (typeof window === 'object') {
59
env.type = 'browser';
610
} else if (typeof importScripts === 'function') {
711
env.type = 'webworker';

0 commit comments

Comments
 (0)