@@ -11,7 +11,7 @@ import { map } from 'rxjs/operators';
1111import stringArgv from 'string-argv' ;
1212import { afterAll , beforeAll , describe , expect , it } from 'vitest' ;
1313
14- import { escapeRegExp } from '../src/utils' ;
14+ import { escapeRegExp } from '../src/utils.js ' ;
1515
1616const isWindows = process . platform === 'win32' ;
1717const createKillMessage = ( prefix : string , signal : 'SIGTERM' | 'SIGINT' | string ) => {
@@ -32,7 +32,10 @@ beforeAll(async () => {
3232 entryPoints : [ path . join ( __dirname , 'concurrently.ts' ) ] ,
3333 platform : 'node' ,
3434 bundle : true ,
35- outfile : path . join ( tmpDir , 'concurrently.js' ) ,
35+ // it doesn't seem like esbuild is able to change a CJS module to ESM, so target CJS instead.
36+ // https://github.com/evanw/esbuild/issues/1921
37+ format : 'cjs' ,
38+ outfile : path . join ( tmpDir , 'concurrently.cjs' ) ,
3639 } ) ;
3740 fs . copyFileSync ( path . join ( __dirname , '..' , 'package.json' ) , path . join ( tmpDir , 'package.json' ) ) ;
3841} , 8000 ) ;
@@ -50,7 +53,7 @@ afterAll(() => {
5053 */
5154const run = ( args : string , ctrlcWrapper ?: boolean ) => {
5255 const spawnFn = ctrlcWrapper ? spawnWithWrapper : spawn ;
53- const child = spawnFn ( 'node' , [ path . join ( tmpDir , 'concurrently.js ' ) , ...stringArgv ( args ) ] , {
56+ const child = spawnFn ( 'node' , [ path . join ( tmpDir , 'concurrently.cjs ' ) , ...stringArgv ( args ) ] , {
5457 cwd : __dirname ,
5558 env : {
5659 ...process . env ,
@@ -152,30 +155,29 @@ describe('exiting conditions', () => {
152155 } ) ;
153156
154157 it ( 'is of success when --success=first and first command to exit succeeds' , async ( ) => {
155- const exit = await run ( '--success=first "echo foo" "node fixtures/sleep.mjs 0.5 && exit 1"' )
158+ const exit = await run ( '--success=first "echo foo" "node fixtures/sleep.js 0.5 && exit 1"' )
156159 . exit ;
157160
158161 expect ( exit . code ) . toBe ( 0 ) ;
159162 } ) ;
160163
161164 it ( 'is of failure when --success=first and first command to exit fails' , async ( ) => {
162- const exit = await run ( '--success=first "exit 1" "node fixtures/sleep.mjs 0.5 && echo foo"' )
165+ const exit = await run ( '--success=first "exit 1" "node fixtures/sleep.js 0.5 && echo foo"' )
163166 . exit ;
164167
165168 expect ( exit . code ) . toBeGreaterThan ( 0 ) ;
166169 } ) ;
167170
168171 describe ( 'is of success when --success=last and last command to exit succeeds' , ( ) => {
169172 it . each ( [ '--success=last' , '-s last' ] ) ( '%s' , async ( arg ) => {
170- const exit = await run ( `${ arg } "exit 1" "node fixtures/sleep.mjs 0.5 && echo foo"` )
171- . exit ;
173+ const exit = await run ( `${ arg } "exit 1" "node fixtures/sleep.js 0.5 && echo foo"` ) . exit ;
172174
173175 expect ( exit . code ) . toBe ( 0 ) ;
174176 } ) ;
175177 } ) ;
176178
177179 it ( 'is of failure when --success=last and last command to exit fails' , async ( ) => {
178- const exit = await run ( '--success=last "echo foo" "node fixtures/sleep.mjs 0.5 && exit 1"' )
180+ const exit = await run ( '--success=last "echo foo" "node fixtures/sleep.js 0.5 && exit 1"' )
179181 . exit ;
180182
181183 expect ( exit . code ) . toBeGreaterThan ( 0 ) ;
@@ -260,7 +262,7 @@ describe('--hide', () => {
260262describe ( '--group' , ( ) => {
261263 it ( 'groups output per process' , async ( ) => {
262264 const lines = await run (
263- '--group "echo foo && node fixtures/sleep.mjs 1 && echo bar" "echo baz"' ,
265+ '--group "echo foo && node fixtures/sleep.js 1 && echo bar" "echo baz"' ,
264266 ) . getLogLines ( ) ;
265267
266268 expect ( lines . slice ( 0 , 4 ) ) . toEqual ( [
@@ -334,54 +336,52 @@ describe('--restart-tries', () => {
334336describe ( '--kill-others' , ( ) => {
335337 describe ( 'kills on success' , ( ) => {
336338 it . each ( [ '--kill-others' , '-k' ] ) ( '%s' , async ( arg ) => {
337- const lines = await run ( `${ arg } "node fixtures/sleep.mjs 10" "exit 0"` ) . getLogLines ( ) ;
339+ const lines = await run ( `${ arg } "node fixtures/sleep.js 10" "exit 0"` ) . getLogLines ( ) ;
338340
339341 expect ( lines ) . toContainEqual ( expect . stringContaining ( '[1] exit 0 exited with code 0' ) ) ;
340342 expect ( lines ) . toContainEqual (
341343 expect . stringContaining ( 'Sending SIGTERM to other processes' ) ,
342344 ) ;
343345 expect ( lines ) . toContainEqual (
344346 expect . stringMatching (
345- createKillMessage ( '[0] node fixtures/sleep.mjs 10' , 'SIGTERM' ) ,
347+ createKillMessage ( '[0] node fixtures/sleep.js 10' , 'SIGTERM' ) ,
346348 ) ,
347349 ) ;
348350 } ) ;
349351 } ) ;
350352
351353 it ( 'kills on failure' , async ( ) => {
352- const lines = await run (
353- '--kill-others "node fixtures/sleep.mjs 10" "exit 1"' ,
354- ) . getLogLines ( ) ;
354+ const lines = await run ( '--kill-others "node fixtures/sleep.js 10" "exit 1"' ) . getLogLines ( ) ;
355355
356356 expect ( lines ) . toContainEqual ( expect . stringContaining ( '[1] exit 1 exited with code 1' ) ) ;
357357 expect ( lines ) . toContainEqual ( expect . stringContaining ( 'Sending SIGTERM to other processes' ) ) ;
358358 expect ( lines ) . toContainEqual (
359- expect . stringMatching ( createKillMessage ( '[0] node fixtures/sleep.mjs 10' , 'SIGTERM' ) ) ,
359+ expect . stringMatching ( createKillMessage ( '[0] node fixtures/sleep.js 10' , 'SIGTERM' ) ) ,
360360 ) ;
361361 } ) ;
362362} ) ;
363363
364364describe ( '--kill-others-on-fail' , ( ) => {
365365 it ( 'does not kill on success' , async ( ) => {
366366 const lines = await run (
367- '--kill-others-on-fail "node fixtures/sleep.mjs 0.5" "exit 0"' ,
367+ '--kill-others-on-fail "node fixtures/sleep.js 0.5" "exit 0"' ,
368368 ) . getLogLines ( ) ;
369369
370370 expect ( lines ) . toContainEqual ( expect . stringContaining ( '[1] exit 0 exited with code 0' ) ) ;
371371 expect ( lines ) . toContainEqual (
372- expect . stringContaining ( '[0] node fixtures/sleep.mjs 0.5 exited with code 0' ) ,
372+ expect . stringContaining ( '[0] node fixtures/sleep.js 0.5 exited with code 0' ) ,
373373 ) ;
374374 } ) ;
375375
376376 it ( 'kills on failure' , async ( ) => {
377377 const lines = await run (
378- '--kill-others-on-fail "node fixtures/sleep.mjs 10" "exit 1"' ,
378+ '--kill-others-on-fail "node fixtures/sleep.js 10" "exit 1"' ,
379379 ) . getLogLines ( ) ;
380380
381381 expect ( lines ) . toContainEqual ( expect . stringContaining ( '[1] exit 1 exited with code 1' ) ) ;
382382 expect ( lines ) . toContainEqual ( expect . stringContaining ( 'Sending SIGTERM to other processes' ) ) ;
383383 expect ( lines ) . toContainEqual (
384- expect . stringMatching ( createKillMessage ( '[0] node fixtures/sleep.mjs 10' , 'SIGTERM' ) ) ,
384+ expect . stringMatching ( createKillMessage ( '[0] node fixtures/sleep.js 10' , 'SIGTERM' ) ) ,
385385 ) ;
386386 } ) ;
387387} ) ;
@@ -482,8 +482,8 @@ describe('--timings', () => {
482482 const tableBottomBorderRegex = / └ [ ─ ┴ ] + ┘ / g;
483483
484484 const timingsTests = {
485- 'shows timings on success' : [ 'node fixtures/sleep.mjs 0.5' , 'exit 0' ] ,
486- 'shows timings on failure' : [ 'node fixtures/sleep.mjs 0.75' , 'exit 1' ] ,
485+ 'shows timings on success' : [ 'node fixtures/sleep.js 0.5' , 'exit 0' ] ,
486+ 'shows timings on failure' : [ 'node fixtures/sleep.js 0.75' , 'exit 1' ] ,
487487 } ;
488488 it . each ( Object . entries ( timingsTests ) ) ( '%s' , async ( _ , commands ) => {
489489 const lines = await run (
0 commit comments