fix: workaround import issue with `node:os` module in node 16.x.x
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 9 Jul 2023 00:02:05 +0000 (02:02 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 9 Jul 2023 00:02:05 +0000 (02:02 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
CHANGELOG.md
src/utils.ts

index 1696e7162c49f74dd78e68eb0cef43ee0de5c5a0..e2d00ee42fe1dac014763e0782eb6c3e16a979b0 100644 (file)
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
+### Fixed
+
+- Workaround import issue with `node:os` module in node 16.x.x.
+
 ## [2.6.11] - 2023-07-09
 
 ### Fixed
index 80e6b9f3b5473dee9e5547930f05ce8b6b473631..128b65da06f6c17b9fd12659521db3d8437a655b 100644 (file)
@@ -1,4 +1,4 @@
-import { cpus, availableParallelism as parallelism } from 'node:os'
+import * as os from 'node:os'
 import type {
   MeasurementStatisticsRequirements,
   WorkerChoiceStrategyOptions
@@ -41,9 +41,9 @@ export const DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS: MeasurementStatisticsR
 export const availableParallelism = (): number => {
   let availableParallelism = 1
   try {
-    availableParallelism = parallelism()
+    availableParallelism = os.availableParallelism()
   } catch {
-    const numberOfCpus = cpus()
+    const numberOfCpus = os.cpus()
     if (Array.isArray(numberOfCpus) && numberOfCpus.length > 0) {
       availableParallelism = numberOfCpus.length
     }