Skip to content

Commit

Permalink
Merge pull request #324 from paulcbetts/electron-compat
Browse files Browse the repository at this point in the history
Electron compatibility
  • Loading branch information
thebigredgeek authored Nov 10, 2016
2 parents 2f9dc36 + 6d2cd13 commit acd3f5f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ function load() {
try {
r = exports.storage.debug;
} catch(e) {}

// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
if ('env' in (process || {})) {
r = process.env.DEBUG;
}

return r;
}

Expand Down
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Detect Electron renderer process, which is node, but we should
* treat as a browser.
*/

if ((process || {}).type === 'renderer') {
module.exports = require('./browser.js');
} else {
module.exports = require('./node.js');
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"browserify": "9.0.3",
"mocha": "*"
},
"main": "./node.js",
"main": "./index.js",
"browser": "./browser.js",
"component": {
"scripts": {
Expand Down

0 comments on commit acd3f5f

Please sign in to comment.