@@ -7,6 +7,7 @@ const pc = require('picocolors');
7
7
const { globSync } = require ( 'tinyglobby' ) ;
8
8
const utils = require ( './utils.js' ) ;
9
9
const { spawn } = require ( 'child_process' ) ;
10
+ const { cpus } = require ( 'os' ) ;
10
11
const host = 'node' + utils . getNodeMajorVersion ( ) ;
11
12
let target = process . argv [ 2 ] || 'host' ;
12
13
if ( target === 'host' ) target = host ;
@@ -18,7 +19,9 @@ if (target === 'host') target = host;
18
19
19
20
const flavor = process . env . FLAVOR || process . argv [ 3 ] || 'all' ;
20
21
21
- const isCI = process . env . CI === 'true' ;
22
+ // const isCI = process.env.CI === 'true';
23
+
24
+ const maxConcurrency = flavor === 'only-npm' ? 1 : Math . max ( cpus ( ) . length , 4 ) ;
22
25
23
26
console . log ( '' ) ;
24
27
console . log ( '*************************************' ) ;
@@ -151,20 +154,13 @@ function runTest(file) {
151
154
} ) ;
152
155
}
153
156
154
- const clearLastLine = ( ) => {
155
- if ( isCI ) return ;
156
- process . stdout . moveCursor ( 0 , - 1 ) ; // up one line
157
- process . stdout . clearLine ( 1 ) ; // from cursor to end
158
- } ;
159
-
160
157
async function run ( ) {
161
158
let done = 0 ;
162
159
let ok = 0 ;
163
160
let failed = [ ] ;
164
161
const start = Date . now ( ) ;
165
162
166
163
function addLog ( log , isError = false ) {
167
- clearLastLine ( ) ;
168
164
if ( isError ) {
169
165
console . error ( log ) ;
170
166
} else {
@@ -176,9 +172,6 @@ async function run() {
176
172
file = path . resolve ( file ) ;
177
173
const startTest = Date . now ( ) ;
178
174
try {
179
- if ( ! isCI ) {
180
- console . log ( pc . gray ( `⏳ ${ file } - ${ done } /${ files . length } ` ) ) ;
181
- }
182
175
await runTest ( file ) ;
183
176
ok ++ ;
184
177
addLog (
@@ -203,8 +196,8 @@ async function run() {
203
196
done ++ ;
204
197
} ) ;
205
198
206
- for ( let i = 0 ; i < promises . length ; i ++ ) {
207
- await promises [ i ] ( ) ;
199
+ for ( let i = 0 ; i < promises . length ; i += maxConcurrency ) {
200
+ await Promise . all ( promises . slice ( i , i + maxConcurrency ) . map ( ( p ) => p ( ) ) ) ;
208
201
}
209
202
210
203
const end = Date . now ( ) ;
@@ -236,6 +229,8 @@ function cleanup() {
236
229
for ( const process of activeProcesses ) {
237
230
process . kill ( ) ;
238
231
}
232
+
233
+ process . exit ( 1 ) ;
239
234
}
240
235
241
236
process . on ( 'SIGINT' , cleanup ) ;
0 commit comments