diff --git a/browser.js b/browser.js index a31d6ff3..d82e9176 100644 --- a/browser.js +++ b/browser.js @@ -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; } diff --git a/index.js b/index.js new file mode 100644 index 00000000..b8bcd909 --- /dev/null +++ b/index.js @@ -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'); +} diff --git a/package.json b/package.json index 5ab1c1c6..318c79d9 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "browserify": "9.0.3", "mocha": "*" }, - "main": "./node.js", + "main": "./index.js", "browser": "./browser.js", "component": { "scripts": {