Skip to content

Commit

Permalink
fix(env): fix env detection compatibility for node, bun, and deno
Browse files Browse the repository at this point in the history
* fix(env): fix env detection compatibility for node, bun, and deno

* bugfix running without navigator.userAgent

---------

Co-authored-by: yunyin <yunyin.guo@tuya.com>
Co-authored-by: plainheart <yhen@all-my-life.cn>
  • Loading branch information
3 people authored Jun 28, 2024
1 parent 7d9f873 commit 71bde87
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ else if (typeof document === 'undefined' && typeof self !== 'undefined') {
env.worker = true;
}
else if (
typeof navigator === 'undefined'
|| navigator.userAgent.indexOf('Node.js') === 0
(typeof process !== 'undefined' && typeof process.version === 'string')
|| (typeof navigator === 'undefined' || typeof navigator.userAgent === 'undefined')
|| (env.hasGlobalWindow && 'Deno' in window)
) {
// In node
env.node = true;
Expand Down

0 comments on commit 71bde87

Please sign in to comment.