1- const replace = require ( 'replace-in-file' ) ;
21const newVersion = process . argv [ 2 ] ;
32
43if ( ! newVersion || ! newVersion . match ( / \d + \. \d + .\d + (?: - \w + (?: \. \w + ) ? ) ? / ) ) {
@@ -11,25 +10,29 @@ function ShowModifiedFiles(changedFiles) {
1110 console . log ( 'Modified files:' , files . join ( ', ' ) ) ;
1211}
1312
14- replace ( {
15- files : [ './src/js/version.ts' ] ,
16- from : / \d + \. \d + .\d + (?: - \w + (?: \. \w + ) ? ) ? / g,
17- to : newVersion ,
18- } )
19- . then ( changedFiles => {
13+ ( async ( ) => {
14+ //New module no longer exports CommonJS format
15+ const { replaceInFile } = await import ( 'replace-in-file' ) ;
16+ try {
17+ const changedFiles = await replaceInFile ( {
18+ files : [ './src/js/version.ts' ] ,
19+ from : / \d + \. \d + .\d + (?: - \w + (?: \. \w + ) ? ) ? / g,
20+ to : newVersion ,
21+ } ) ;
22+
2023 ShowModifiedFiles ( changedFiles ) ;
21- return replace ( {
24+ const changedPluginFile = await replaceInFile ( {
2225 files : [ 'plugin.xml' ] ,
2326 // from: /id="@sentry\/cordova" version="\d+\.\d+.\d+"/g,
2427 // to: `id="@sentry/cordova" version="${pjson.version}"`,
2528 from : / i d = " s e n t r y - c o r d o v a " v e r s i o n = " \d + .\d + .\d + [ ^ " ] * " / g,
2629 to : `id="sentry-cordova" version="${ newVersion } "` ,
2730 } ) ;
28- } )
29- . then ( changedFiles => {
30- ShowModifiedFiles ( changedFiles ) ;
31- } )
32- . catch ( error => {
31+
32+ ShowModifiedFiles ( changedPluginFile ) ;
33+ }
34+ catch ( error ) {
3335 console . error ( 'Error occurred:' , error ) ;
3436 process . exit ( 1 ) ;
35- } ) ;
37+ } ;
38+ } ) ( ) ;
0 commit comments