@@ -109,6 +109,21 @@ function updateDefaultInJson(newVersion, jsonFile) {
109109 }
110110}
111111
112+ function updateVersionInTestFile ( newVersion , testFile ) {
113+ try {
114+ const content = fs . readFileSync ( testFile , 'utf8' ) ;
115+
116+ // Replace version in the test file using regex to find the version pattern
117+ const versionRegex = / ( \d + \. \d + \. \d + ) / g;
118+ const updatedContent = content . replace ( versionRegex , newVersion ) ;
119+
120+ fs . writeFileSync ( testFile , updatedContent ) ;
121+ return true ;
122+ } catch ( error ) {
123+ throw new Error ( `Could not update test file ${ testFile } : ${ error . message } ` ) ;
124+ }
125+ }
126+
112127function main ( ) {
113128 // Check command line arguments
114129 const args = process . argv . slice ( 2 ) ;
@@ -122,6 +137,10 @@ function main() {
122137 const newVersion = args [ 0 ] ;
123138 const yamlFile = '.github/workflows/publish-new-image-version.yaml' ;
124139 const jsonFile = 'features/src/ruby/devcontainer-feature.json' ;
140+ const testFiles = [
141+ 'features/test/ruby/test.sh' ,
142+ 'features/test/ruby/with_rbenv.sh'
143+ ] ;
125144
126145 // Validate version format
127146 if ( ! validateVersionFormat ( newVersion ) ) {
@@ -140,6 +159,14 @@ function main() {
140159 process . exit ( 1 ) ;
141160 }
142161
162+ // Check if test files exist
163+ for ( const testFile of testFiles ) {
164+ if ( ! fs . existsSync ( testFile ) ) {
165+ log ( `${ emoji . error } Error: ${ testFile } not found` , 'red' ) ;
166+ process . exit ( 1 ) ;
167+ }
168+ }
169+
143170 try {
144171 // Check if version already exists
145172 if ( versionExistsInYaml ( newVersion , yamlFile ) ) {
@@ -177,6 +204,15 @@ function main() {
177204 log ( 'Default version remains unchanged' ) ;
178205 }
179206
207+ // Update test files
208+ log ( '' ) ;
209+ log ( `${ emoji . edit } Updating test files...` , 'blue' ) ;
210+ for ( const testFile of testFiles ) {
211+ updateVersionInTestFile ( newVersion , testFile ) ;
212+ log ( `${ emoji . check } Updated ${ testFile } ` , 'green' ) ;
213+ filesModified . push ( testFile ) ;
214+ }
215+
180216 // Success message
181217 log ( '' ) ;
182218 log ( `${ emoji . party } Successfully added Ruby version ${ newVersion } !` , 'green' ) ;
0 commit comments