Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix nwjs support (#569)
  • Loading branch information
miaulightouch authored and Qix- committed Jul 26, 2018
1 parent 05b0ceb commit 207a6a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/browser.js
Expand Up @@ -39,7 +39,7 @@ function useColors() {
// NB: In an Electron preload script, document will be defined but not fully
// initialized. Since we know we're in Chrome, we'll just detect this case
// explicitly
if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
return true;
}

Expand Down
5 changes: 3 additions & 2 deletions src/index.js
@@ -1,9 +1,10 @@
/**
* Detect Electron renderer process, which is node, but we should
* Detect Electron renderer / nwjs process, which is node, but we should
* treat as a browser.
*/

if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true) {

if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
module.exports = require('./browser.js');
} else {
module.exports = require('./node.js');
Expand Down

0 comments on commit 207a6a2

Please sign in to comment.