Skip to content

Commit

Permalink
Make the detection of Node.js environments on Electron strict.
Browse files Browse the repository at this point in the history
The main process and its child processes should be detected as Node.js environments.
  • Loading branch information
tamuratak committed Jul 11, 2020
1 parent 7dabc5e commit ea75dff
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/shared/is_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

// NW.js / Electron is a browser context, but copies some Node.js objects; see
// http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/#access-nodejs-and-nwjs-api-in-browser-context
// https://electronjs.org/docs/api/process#processversionselectron
// https://www.electronjs.org/docs/api/process#processversionselectron
// https://www.electronjs.org/docs/api/process#processtype-readonly
const isNodeJS =
typeof process === "object" &&
process + "" === "[object process]" &&
!process.versions.nw &&
!process.versions.electron;
!(process.versions.electron && process.type && process.type !== "browser");

export { isNodeJS };

0 comments on commit ea75dff

Please sign in to comment.