11import { spawn } from 'child_process' ;
2+ import { join } from 'path' ;
23
34const DEBUG = ! ! process . env . DEBUG ;
45
56async function getMeasurements ( instrumentFile ) {
6- const args = [ './src/app.mjs' ] ;
7+ const curPath = process . cwd ( ) ;
8+ const args = [ join ( curPath , './src/app.mjs' ) ] ;
79
810 if ( instrumentFile ) {
9- args . unshift ( '--import' , instrumentFile ) ;
11+ args . unshift ( '--import' , join ( curPath , instrumentFile ) ) ;
1012 }
1113
1214 const cmd = `node ${ args . join ( ' ' ) } ` ;
@@ -17,21 +19,18 @@ async function getMeasurements(instrumentFile) {
1719
1820 log ( 'Child process started, waiting for example app...' ) ;
1921
20- appProcess . stderr . on ( 'data' , data => {
21- log ( `appProcess stderr: ${ data } ` ) ;
22- } ) ;
23-
24- appProcess . on ( 'exit' , code => {
25- log ( `appProcess exited with code ${ code } ` ) ;
26- } ) ;
27-
28- await new Promise ( resolve => {
22+ await new Promise ( ( resolve , reject ) => {
2923 appProcess . stdout . on ( 'data' , data => {
3024 log ( `appProcess: ${ data } ` ) ;
3125 if ( `${ data } ` . includes ( 'Example app listening on port' ) ) {
3226 resolve ( ) ;
3327 }
3428 } ) ;
29+
30+ appProcess . stderr . on ( 'data' , data => {
31+ log ( `appProcess stderr: ${ data } ` ) ;
32+ reject ( data ) ;
33+ } ) ;
3534 } ) ;
3635
3736 log ( 'Example app listening, running autocannon...' ) ;
0 commit comments