1- const core = require ( ' @actions/core' ) ;
2- const github = require ( ' @actions/github' ) ;
3- const fs = require ( 'fs' )
1+ const core = require ( " @actions/core" ) ;
2+ const github = require ( " @actions/github" ) ;
3+ const fs = require ( "fs" ) ;
44
55try {
6- // get the input values
7- const filePath = core . getInput ( ' filepath' ) ;
6+ // get the input values
7+ const filePath = core . getInput ( " filepath" ) ;
88 console . log ( filePath ) ;
9- const versionNumber = core . getInput ( 'versionnumber' ) ;
10- console . log ( versionNumber ) ;
11-
12- fs . readFile ( filePath , 'utf8' , function ( err , data ) {
13- if ( err ) {
14- return console . log ( err ) ;
15- }
16- //<ApplicationVersion>1</ApplicationVersion>
17- //var replacementString = `<ApplicationVersion>${versionNumber}</ApplicationVersion>`;
18- //var result = data.replace('<ApplicationVersion>1</ApplicationVersion>', replacementString);
19- //var replacementString = `<ApplicationDisplayVersion>${versionNumber}</ApplicationDisplayVersion>`;
20- //var result = result.replace('<ApplicationDisplayVersion>1</ApplicationDisplayVersion>', replacementString);
9+ const versionNumber = core . getInput ( "versionnumber" ) ;
10+ console . log ( versionNumber ) ;
2111
22- var versionReplacementString = `<ApplicationVersion>${ versionNumber } </ApplicationVersion>` ;
23- console . log ( versionReplacementString ) ;
24- var displayVersionReplacementString = `<ApplicationDisplayVersion>${ versionNumber } </ApplicationDisplayVersion>` ;
25- console . log ( displayVersionReplacementString ) ;
26- var result = data . replace ( '<ApplicationVersion>1</ApplicationVersion>' , versionReplacementString ) ;
27- result = result . replace ( '<ApplicationDisplayVersion>${versionNumber}</ApplicationDisplayVersion>' , displayVersionReplacementString ) ;
28-
29- console . log ( result ) ;
30- fs . writeFile ( filePath , result , 'utf8' , function ( err ) {
31- if ( err ) return console . log ( err ) ;
32- } ) ;
33- } ) ;
12+ fs . readFile ( filePath ,
13+ "utf8" ,
14+ function ( err , data ) {
15+ if ( err ) {
16+ return console . log ( err ) ;
17+ }
18+
19+ var versionReplacementString = `<ApplicationVersion>${ versionNumber } </ApplicationVersion>` ;
20+ console . log ( versionReplacementString ) ;
21+ var displayVersionReplacementString =
22+ `<ApplicationDisplayVersion>${ versionNumber } </ApplicationDisplayVersion>` ;
23+ console . log ( displayVersionReplacementString ) ;
24+ var result = data . replace ( "<ApplicationVersion>1</ApplicationVersion>" , versionReplacementString ) ;
25+ result = result . replace ( "<ApplicationDisplayVersion>${versionNumber}</ApplicationDisplayVersion>" ,
26+ displayVersionReplacementString ) ;
27+
28+ console . log ( result ) ;
29+ fs . writeFile ( filePath ,
30+ result ,
31+ "utf8" ,
32+ function ( err ) {
33+ if ( err ) return console . log ( err ) ;
34+ } ) ;
35+ fs . readFile ( filePath ,
36+ "utf8" ,
37+ function ( err , data ) {
38+ if ( err ) {
39+ return console . log ( err ) ;
40+ }
41+ console . log ( data ) ;
42+ } ) ;
43+
44+
45+ } ) ;
3446
3547} catch ( error ) {
36- core . setFailed ( error . message ) ;
37- }
48+ core . setFailed ( error . message ) ;
49+ }
0 commit comments