tape-six-proc 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -22,6 +22,7 @@ has the same usage as `tape6`.
22
22
 
23
23
  The most recent releases:
24
24
 
25
+ * 1.0.2 *Fixed concurrency detection. Updated dependencies.*
25
26
  * 1.0.1 *Updated dependencies.*
26
27
  * 1.0.0 *The first official release.*
27
28
  * 0.12.1 *Updated dependencies, which included fixes for Deno.*
@@ -3,6 +3,7 @@
3
3
  'use strict';
4
4
 
5
5
  import process from 'node:process';
6
+ import os from 'node:os';
6
7
  import {fileURLToPath} from 'node:url';
7
8
 
8
9
  import {resolveTests, resolvePatterns} from 'tape-six/utils/config.js';
@@ -95,7 +96,18 @@ const config = () => {
95
96
  } else {
96
97
  parallel = 0;
97
98
  }
98
- if (!parallel) parallel = navigator.hardwareConcurrency;
99
+ if (!parallel) {
100
+ if (typeof navigator !== 'undefined' && navigator.hardwareConcurrency) {
101
+ parallel = navigator.hardwareConcurrency;
102
+ } else {
103
+ try {
104
+ parallel = os.availableParallelism();
105
+ } catch (e) {
106
+ void e;
107
+ parallel = 1;
108
+ }
109
+ }
110
+ }
99
111
 
100
112
  options.runFileArgs = runFileArgs;
101
113
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tape-six-proc",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Helper for TAP the test harness for the modern JavaScript (ES6) to run tests in separate processes.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -26,6 +26,6 @@
26
26
  "homepage": "https://github.com/uhop/tape-six-proc#readme",
27
27
  "dependencies": {
28
28
  "dollar-shell": "^1.1.0",
29
- "tape-six": "^1.0.3"
29
+ "tape-six": "^1.1.2"
30
30
  }
31
31
  }
package/src/TestWorker.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import process from 'node:process';
2
+ import os from 'node:os';
2
3
  import {sep} from 'node:path';
3
4
  import {pathToFileURL, fileURLToPath} from 'node:url';
4
5
 
@@ -13,7 +14,7 @@ import parse from './chain/jsonl-parse.js';
13
14
  const baseName = pathToFileURL(process.cwd() + sep);
14
15
 
15
16
  export default class TestWorker extends EventServer {
16
- constructor(reporter, numberOfTasks = navigator.hardwareConcurrency, options) {
17
+ constructor(reporter, numberOfTasks = TestWorker.getConcurrency(), options) {
17
18
  super(reporter, numberOfTasks, options);
18
19
  this.counter = 0;
19
20
  this.idToWorker = {};
@@ -64,4 +65,16 @@ export default class TestWorker extends EventServer {
64
65
  delete this.idToWorker[id];
65
66
  }
66
67
  }
68
+ static getConcurrency() {
69
+ if (typeof navigator !== 'undefined' && navigator.hardwareConcurrency) {
70
+ return navigator.hardwareConcurrency;
71
+ }
72
+ try {
73
+ return os.availableParallelism();
74
+ } catch (e) {
75
+ void e;
76
+ // squelch
77
+ }
78
+ return 1;
79
+ }
67
80
  }
@@ -1,5 +1,7 @@
1
- # The current version: 0.12.x
1
+ # The current version: 1.x
2
2
 
3
+ * 1.0.2 *Fixed concurrency detection. Updated dependencies.*
4
+ * 1.0.1 *Updated dependencies.*
3
5
  * 1.0.0 *The first official release.*
4
6
  * 0.12.1 *Updated dependencies, which included fixes for Deno.*
5
7
  * 0.12.0 *Initial release.*