File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,18 @@ module.exports = {
2424 } )
2525 } )
2626 }
27+
28+ // val PUBG_API_WRAPPER by extra("0.8.1")
29+ const regexKotlinValExtra = new RegExp ( `${ variableName } .+\(("|')${ oldVersion } ("|')\)` )
30+ const regexKotlinValMatches = regexKotlinValExtra . exec ( body )
31+ if ( regexKotlinValMatches && regexKotlinValMatches . length ) {
32+ regexKotlinValMatches . filter ( it => it . includes ( dependency . oldVersion ) ) . forEach ( match => {
33+ replaceActions . push ( {
34+ searchValue : match ,
35+ replaceValue : match . replace ( dependency . oldVersion , dependency . version )
36+ } )
37+ } )
38+ }
2739 }
2840
2941 // compile 'de.kevcodez:pubg-api-wrapper:1.0.0'
Original file line number Diff line number Diff line change @@ -81,6 +81,28 @@ test('Replace kotlin plugin version', () => {
8181 const replacedVersion = replaceText ( `id("com.github.ben-manes.versions") version "0.22.0"` , pluginDependency )
8282 expect ( replacedVersion ) . toBe ( `id("com.github.ben-manes.versions") version "0.24.0"` )
8383} )
84+ test ( 'Replace kotlin version with extra val without braces in reference' , ( ) => {
85+ const replacedVersion = replaceText ( `
86+ val PUBG_API_WRAPPER by extra("0.8.1")
87+
88+ dependencies {
89+ implementation("de.kevcodez:pubg-api-wrapper:$PUBG_API_WRAPPER")
90+ }
91+ ` , dependency )
92+
93+ expect ( replacedVersion ) . toContain ( `val PUBG_API_WRAPPER by extra("1.0.0")` )
94+ } )
95+ test ( 'Replace kotlin version with extra val with braces in reference' , ( ) => {
96+ const replacedVersion = replaceText ( `
97+ val PUBG_API_WRAPPER by extra("0.8.1")
98+
99+ dependencies {
100+ implementation("de.kevcodez:pubg-api-wrapper:$\{PUBG_API_WRAPPER\}")
101+ }
102+ ` , dependency )
103+
104+ expect ( replacedVersion ) . toContain ( `val PUBG_API_WRAPPER by extra("1.0.0")` )
105+ } )
84106
85107function replaceText ( source , dependency ) {
86108 const replaceVersionActions = ReplaceVersion . replace ( source , dependency )
You can’t perform that action at this time.
0 commit comments