Browse Source

Add electron environment check, fix #376

pull/379/head
Jerome Wu 5 years ago
parent
commit
b8aba2eddd
  1. 5
      package-lock.json
  2. 1
      package.json
  3. 6
      src/utils/getEnvironment.js

5
package-lock.json generated

@ -4870,6 +4870,11 @@
} }
} }
}, },
"is-electron": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/is-electron/-/is-electron-2.2.0.tgz",
"integrity": "sha512-SpMppC2XR3YdxSzczXReBjqs2zGscWQpBIKqwXYBFic0ERaxNVgwLCHwOLZeESfdJQjX0RDvrJ1lBXX2ij+G1Q=="
},
"is-extendable": { "is-extendable": {
"version": "0.1.1", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",

1
package.json

@ -60,6 +60,7 @@
"bmp-js": "^0.1.0", "bmp-js": "^0.1.0",
"file-type": "^12.4.1", "file-type": "^12.4.1",
"idb-keyval": "^3.2.0", "idb-keyval": "^3.2.0",
"is-electron": "^2.2.0",
"is-url": "1.2.2", "is-url": "1.2.2",
"node-fetch": "^2.6.0", "node-fetch": "^2.6.0",
"opencollective-postinstall": "^2.0.2", "opencollective-postinstall": "^2.0.2",

6
src/utils/getEnvironment.js

@ -1,7 +1,11 @@
const isElectron = require('is-electron');
module.exports = (key) => { module.exports = (key) => {
const env = {}; const env = {};
if (typeof window === 'object') { if (isElectron()) {
env.type = 'electron';
} else if (typeof window === 'object') {
env.type = 'browser'; env.type = 'browser';
} else if (typeof importScripts === 'function') { } else if (typeof importScripts === 'function') {
env.type = 'webworker'; env.type = 'webworker';

Loading…
Cancel
Save