vona-cli-set-api 1.1.129 → 1.1.130

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.
@@ -5,6 +5,7 @@ import { globby } from 'globby';
5
5
  import { createWriteStream } from 'node:fs';
6
6
  import os from 'node:os';
7
7
  import path from 'node:path';
8
+ import { pipeline } from 'node:stream/promises';
8
9
  import { run } from 'node:test';
9
10
  import { lcov, spec } from 'node:test/reporters';
10
11
  import { fileURLToPath } from 'node:url';
@@ -100,19 +101,24 @@ async function testRun(projectPath, coverage, patterns) {
100
101
  }
101
102
  });
102
103
  const summaryPromise = waitForTestSummary(testStream);
103
- if (coverage) {
104
- const reporterDir = path.join(projectPath, 'coverage');
105
- fse.ensureDirSync(reporterDir);
106
- const reporterLcov = createWriteStream(path.join(reporterDir, 'lcov.info'));
107
- testStream.compose(lcov).pipe(reporterLcov);
108
- }
109
- else {
110
- testStream.compose(spec).pipe(process.stdout);
111
- }
112
- const summarySuccess = await summaryPromise;
104
+ const reporterPromise = coverage
105
+ ? (() => {
106
+ const reporterDir = path.join(projectPath, 'coverage');
107
+ fse.ensureDirSync(reporterDir);
108
+ const reporterLcov = createWriteStream(path.join(reporterDir, 'lcov.info'));
109
+ return pipeline(testStream.compose(lcov), reporterLcov);
110
+ })()
111
+ : pipeline(testStream.compose(spec), process.stdout, { end: false });
112
+ const [summarySuccess, [, reporterError]] = await Promise.all([
113
+ summaryPromise,
114
+ catchError(() => reporterPromise),
115
+ ]);
113
116
  if (!summarySuccess) {
114
117
  throw new Error('node:test reported failed tests');
115
118
  }
119
+ if (reporterError) {
120
+ throw reporterError;
121
+ }
116
122
  }
117
123
  catch (error) {
118
124
  testError = error;
@@ -139,15 +145,19 @@ function waitForTestSummary(testStream) {
139
145
  }
140
146
  async function prepareConcurrency(app) {
141
147
  // check
148
+ const configured = process.env.TEST_CONCURRENCY;
142
149
  let concurrency = 1;
143
- if (process.env.TEST_CONCURRENCY === 'true') {
144
- concurrency = os.cpus().length;
145
- }
146
- else if (process.env.TEST_CONCURRENCY === 'false') {
150
+ if (configured === 'false') {
147
151
  concurrency = 1;
148
152
  }
153
+ else if (configured === undefined || configured === 'true') {
154
+ concurrency = Math.max(1, os.cpus().length);
155
+ }
149
156
  else {
150
- concurrency = Number.parseInt(process.env.TEST_CONCURRENCY);
157
+ concurrency = Number.parseInt(configured, 10);
158
+ if (!Number.isSafeInteger(concurrency) || concurrency < 1) {
159
+ throw new Error(`TEST_CONCURRENCY must be true, false, or a positive integer; received ${configured}`);
160
+ }
151
161
  }
152
162
  if (concurrency === 1)
153
163
  return concurrency;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-cli-set-api",
3
- "version": "1.1.129",
4
- "gitHead": "cd41414765dfc186953f59e31d654ecb8ab2ed41",
3
+ "version": "1.1.130",
4
+ "gitHead": "94b4f86ba6b9015d9add7de4e03e19db9a084fd2",
5
5
  "description": "vona cli-set-api",
6
6
  "keywords": [
7
7
  "framework",
@@ -73,7 +73,7 @@
73
73
  "ts-node-maintained": "^10.9.6",
74
74
  "urllib": "^4.9.0",
75
75
  "uuid": "^11.1.0",
76
- "vona-core": "^5.1.32",
76
+ "vona-core": "^5.1.33",
77
77
  "why-is-node-running": "^3.2.2",
78
78
  "yargs-parser": "^22.0.0"
79
79
  }