Merge pull request #10681 from CodeDaraW/fix-electron

fix: electron enviroment detection
This commit is contained in:
Tim van der Meij 2019-03-26 23:11:09 +01:00 committed by GitHub
commit cf1acd3eaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,9 +15,10 @@
/* globals module, process */ /* globals module, process */
module.exports = function isNodeJS() { module.exports = function isNodeJS() {
// NW.js is a browser context, but copies some Node.js objects; see // NW.js / Electron is a browser context, but copies some Node.js objects; see
// http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/#access-nodejs-and-nwjs-api-in-browser-context // http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/#access-nodejs-and-nwjs-api-in-browser-context
// https://electronjs.org/docs/api/process#processversionselectron
return typeof process === 'object' && return typeof process === 'object' &&
process + '' === '[object process]' && process + '' === '[object process]' &&
!process.versions['nw']; !process.versions['nw'] && !process.versions['electron'];
}; };