11/* eslint-disable no-console */
2- const versions = [ '3.10' , '3.13' ] ;
32
4- const { spawn } = require ( 'child_process' ) ;
3+ // const versions = [process.env.EMBER_VERSION]
4+ const allVersions = [ '3.10' , '3.13' ] ;
5+
56const execa = require ( 'execa' ) ;
67const path = require ( 'path' ) ;
78
9+ async function kill ( subprocess ) {
10+ setTimeout ( ( ) => {
11+ subprocess . cancel ( ) ;
12+ subprocess . kill ( 'SIGTERM' ) ;
13+ } , 1000 ) ;
14+
15+ console . log ( `Requesting SIGTERM of ${ subprocess . pid } ` ) ;
16+ return new Promise ( resolve => {
17+ setTimeout ( ( ) => {
18+ resolve ( ) ;
19+ } , 1000 ) ;
20+ } ) ;
21+ }
22+
823async function runTestForVersion ( version ) {
924 console . log ( `
1025 Running Integration Test for Ember ${ version }
@@ -22,8 +37,7 @@ async function runTestForVersion(version) {
2237 console . log ( 'starting serve' ) ;
2338
2439 // We use spawn for this one so we can kill it later without throwing an error
25- const emberServe = spawn ( 'yarn' , [ 'start' ] , execOpts ) ;
26- emberServe . stderr . pipe ( process . stderr ) ;
40+ const emberServe = execa ( 'yarn' , [ 'start' ] , { cwd : inputDir } ) ;
2741
2842 await new Promise ( resolve => {
2943 emberServe . stdout . on ( 'data' , data => {
@@ -39,7 +53,7 @@ async function runTestForVersion(version) {
3953
4054 console . log ( 'codemod complete, ending serve' ) ;
4155
42- emberServe . kill ( 'SIGTERM' ) ;
56+ await kill ( emberServe ) ;
4357
4458 console . log ( 'comparing results' ) ;
4559
@@ -55,13 +69,19 @@ async function runTestForVersion(version) {
5569 console . log ( 'codemod ran successfully! 🎉' ) ;
5670}
5771
58-
5972( async ( ) => {
60- for ( let version of versions ) {
61- await runTestForVersion ( version ) ;
73+ let emberVersion = process . env . EMBER_VERSION ;
74+ if ( ! emberVersion ) {
75+ console . error ( `No EMBER_VERSION set. No scenarios to run.` ) ;
76+ process . exit ( 1 ) ;
6277 }
6378
64- process . exit ( 0 ) ;
65- } ) ( ) ;
79+ if ( ! allVersions . includes ( `${ emberVersion } ` ) ) {
80+ console . error ( `EMBER_VERSION is not allowed. Available: ${ allVersions . join ( ', ' ) } ` ) ;
81+ process . exit ( 1 ) ;
82+ }
6683
84+ await runTestForVersion ( emberVersion ) ;
6785
86+ process . exit ( 0 ) ;
87+ } ) ( ) ;
0 commit comments