| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -6,6 +6,7 @@ npm-debug.log | |
| yarn-error.log | ||
| /dist/ | ||
| /coverage/ | ||
| .nyc_output/ | ||
|
|
||
| # lockfiles | ||
| yarn.lock | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -10,6 +10,14 @@ exports.load = load; | |
| exports.useColors = useColors; | ||
| exports.storage = localstorage(); | ||
|
|
||
| /** | ||
| * Are we in Electron? | ||
| * @returns {boolean} | ||
| */ | ||
| function isElectron() { | ||
| return typeof process !== 'undefined' && (process.type === 'renderer' || process.__nwjs); | ||
| } | ||
|
|
||
| /** | ||
| * Colors. | ||
| */ | ||
| Expand Down Expand Up | @@ -106,7 +114,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' || window.process.__nwjs)) { | ||
| if (isElectron()) { | ||
| return true; | ||
| } | ||
|
|
||
| Expand Down Expand Up | @@ -204,20 +212,12 @@ function save(namespaces) { | |
| * @api private | ||
| */ | ||
| function load() { | ||
| let r; | ||
| try { | ||
| r = exports.storage.getItem('debug'); | ||
| return exports.storage.getItem('debug'); | ||
| } catch (error) { | ||
| // Swallow | ||
| // XXX (@Qix-) should we be logging these? | ||
| } | ||
|
|
||
| // If debug isn't set in LS, and we're in Electron, try to load $DEBUG | ||
| if (!r && typeof process !== 'undefined' && 'env' in process) { | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis is the critical part that was exposing process.env in the browser. It's been pulled out into the electron-specific flow.
Sorry, something went wrong.
All reactions
|
||
| r = process.env.DEBUG; | ||
| } | ||
|
|
||
| return r; | ||
| } | ||
|
|
||
| /** | ||
| Expand All | @@ -242,18 +242,23 @@ function localstorage() { | |
| } | ||
| } | ||
|
|
||
| module.exports = require('./common')(exports); | ||
| if (isElectron()) { | ||
| module.exports = exports; | ||
| module.exports.humanize = require('ms'); | ||
| } else { | ||
| module.exports = require('./common')(exports); | ||
|
|
||
| const {formatters} = module.exports; | ||
| const {formatters} = module.exports; | ||
|
|
||
| /** | ||
| * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. | ||
| */ | ||
| /** | ||
| * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. | ||
| */ | ||
|
|
||
| formatters.j = function (v) { | ||
| try { | ||
| return JSON.stringify(v); | ||
| } catch (error) { | ||
| return '[UnexpectedJSONParseError]: ' + error.message; | ||
| } | ||
| }; | ||
| formatters.j = function (v) { | ||
| try { | ||
| return JSON.stringify(v); | ||
| } catch (error) { | ||
| return '[UnexpectedJSONParseError]: ' + error.message; | ||
| } | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| exports = require('./browser'); | ||
|
|
||
| const browserLoad = exports.load; | ||
|
|
||
| // If debug isn't set in LS, and we're in Electron, try to load $DEBUG | ||
| exports.load = function () { | ||
| let r = browserLoad(); | ||
| if (!r && 'env' in process) { | ||
| r = process.env.DEBUG; | ||
| } | ||
| return r; | ||
| }; | ||
|
|
||
| module.exports = require('./common')(exports); | ||
|
|
||
| const {formatters} = module.exports; | ||
|
|
||
| /** | ||
| * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. | ||
| */ | ||
|
|
||
| formatters.j = function (v) { | ||
| try { | ||
| return JSON.stringify(v); | ||
| } catch (error) { | ||
| return '[UnexpectedJSONParseError]: ' + error.message; | ||
| } | ||
| }; |
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySo we can see that browser env was selected.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.