Add electron option when detecting environment
This commit is contained in:
parent
c506475a76
commit
1bacf193d9
5
package-lock.json
generated
5
package-lock.json
generated
@ -4560,6 +4560,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": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
|
||||
|
@ -40,6 +40,7 @@
|
||||
"dependencies": {
|
||||
"@ffmpeg/core": "^0.5.0",
|
||||
"idb": "^4.0.5",
|
||||
"is-electron": "^2.2.0",
|
||||
"is-url": "^1.2.4",
|
||||
"node-fetch": "^2.6.0",
|
||||
"regenerator-runtime": "^0.13.3",
|
||||
|
@ -1,10 +1,21 @@
|
||||
const isElectron = require('is-electron');
|
||||
|
||||
module.exports = (key) => {
|
||||
const env = {
|
||||
type: (typeof window !== 'undefined') && (typeof window.document !== 'undefined') ? 'browser' : 'node',
|
||||
};
|
||||
const env = {};
|
||||
|
||||
if (isElectron()) {
|
||||
env.type = 'electron';
|
||||
} else if (typeof window === 'object') {
|
||||
env.type = 'browser';
|
||||
} else if (typeof importScripts === 'function') {
|
||||
env.type = 'webworker';
|
||||
} else if (typeof process === 'object' && typeof require === 'function') {
|
||||
env.type = 'node';
|
||||
}
|
||||
|
||||
if (typeof key === 'undefined') {
|
||||
return env;
|
||||
}
|
||||
|
||||
return env[key];
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user