Skip to content

Commit

Permalink
fix: make Node.js environment detection robust w.r.t. JSDOM (#6148)
Browse files Browse the repository at this point in the history
Previously Node.js was detected by the lack of `global.document` which doesn’t work in case JSDOM is being used in Node.js. Instead, we now detect `process.versions.node`, like here: https://github.com/MatthewSH/is-node/commit/426943ae936536f9c2fd10fd58a9a46b59470097#diff-168726dbe96b3ce427e7fedce31bb0bc.

Fixes #6147.
  • Loading branch information
wojtekmaj committed Jul 3, 2020
1 parent 054fa2e commit aee8fda
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/environment.ts
Expand Up @@ -14,4 +14,8 @@
* limitations under the License.
*/

export const isNode = typeof document === 'undefined';
export const isNode = !!(
typeof process !== 'undefined' &&
process.versions &&
process.versions.node
);

0 comments on commit aee8fda

Please sign in to comment.