From a29adef252623a74af6cd58ca3c4ca2ef5dbfe64 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 9 Jan 2019 15:36:24 -0800 Subject: [PATCH] test,worker: simplify common.isMainThread Now that `worker_threads` do not require a flag, the logic around loading `isMainThread` can be removed. PR-URL: https://github.com/nodejs/node/pull/25426 Reviewed-By: Eugene Ostroukhov Reviewed-By: Ruben Bridgewater Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig --- test/common/index.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/test/common/index.js b/test/common/index.js index c84933fd6eb3b3..ae9dceae94d69e 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -46,13 +46,7 @@ const noop = () => {}; const hasCrypto = Boolean(process.versions.openssl); -const isMainThread = (() => { - if (require('module').builtinModules.includes('worker_threads')) { - return require('worker_threads').isMainThread; - } - // Worker module not enabled → only a single main thread exists. - return true; -})(); +const { isMainThread } = require('worker_threads'); // Check for flags. Skip this for workers (both, the `cluster` module and // `worker_threads`) and child processes.