Add electron option when detecting environment
This commit is contained in:
@@ -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];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user