diff options
author | Rich Trott <rtrott@gmail.com> | 2018-12-28 08:55:38 -0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-12-30 16:28:21 -0800 |
commit | 9c2b14013bfa9e44dcb38602b2b57e4b8698b7b4 (patch) | |
tree | 44f246bb9090745ec09077bd615ecadc5300db26 /test | |
parent | 39a2ac4c6ba189fd1596572655dbd6c8daff2d5f (diff) | |
download | android-node-v8-9c2b14013bfa9e44dcb38602b2b57e4b8698b7b4.tar.gz android-node-v8-9c2b14013bfa9e44dcb38602b2b57e4b8698b7b4.tar.bz2 android-node-v8-9c2b14013bfa9e44dcb38602b2b57e4b8698b7b4.zip |
test: remove try/catch in common.isMainThread
Refactor common.isMainThread.
PR-URL: https://github.com/nodejs/node/pull/25249
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/common/index.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/test/common/index.js b/test/common/index.js index 5ac79f4998..5d9a4b31e3 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -39,12 +39,11 @@ const noop = () => {}; const hasCrypto = Boolean(process.versions.openssl); const isMainThread = (() => { - try { + if (require('module').builtinModules.includes('worker_threads')) { return require('worker_threads').isMainThread; - } catch { - // Worker module not enabled → only a single main thread exists. - return true; } + // Worker module not enabled → only a single main thread exists. + return true; })(); // Check for flags. Skip this for workers (both, the `cluster` module and |