Skip to content

Commit acd3f5f

Browse files
Merge pull request #324 from paulcbetts/electron-compat
Electron compatibility
2 parents 2f9dc36 + 6d2cd13 commit acd3f5f

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

browser.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ function load() {
142142
try {
143143
r = exports.storage.debug;
144144
} catch(e) {}
145+
146+
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
147+
if ('env' in (process || {})) {
148+
r = process.env.DEBUG;
149+
}
150+
145151
return r;
146152
}
147153

index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Detect Electron renderer process, which is node, but we should
3+
* treat as a browser.
4+
*/
5+
6+
if ((process || {}).type === 'renderer') {
7+
module.exports = require('./browser.js');
8+
} else {
9+
module.exports = require('./node.js');
10+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"browserify": "9.0.3",
2525
"mocha": "*"
2626
},
27-
"main": "./node.js",
27+
"main": "./index.js",
2828
"browser": "./browser.js",
2929
"component": {
3030
"scripts": {

0 commit comments

Comments
 (0)