fix: make Node.js environment detection robust w.r.t. JSDOM (#6148)

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: 426943ae93 (diff-168726dbe96b3ce427e7fedce31bb0bc).

Fixes #6147.
This commit is contained in:
Wojciech Maj 2020-07-03 10:56:28 +02:00 committed by GitHub
parent 054fa2e45d
commit aee8fda98a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
);