@@ -16,9 +16,11 @@ module.exports = {
1616 const regexVariableDefinition = new RegExp ( `(${ variableName } (\\s+)?=(\\s+)?('|")${ oldVersion } ('|"))` , "ig" )
1717 const regexVariableDefinitionMatches = regexVariableDefinition . exec ( modifiedBody )
1818
19- regexVariableDefinitionMatches . filter ( it => it . includes ( dependency . oldVersion ) ) . forEach ( match => {
20- modifiedBody = modifiedBody . replace ( match , match . replace ( dependency . oldVersion , dependency . version ) )
21- } )
19+ if ( regexVariableDefinitionMatches && regexVariableDefinitionMatches . length ) {
20+ regexVariableDefinitionMatches . filter ( it => it . includes ( dependency . oldVersion ) ) . forEach ( match => {
21+ modifiedBody = modifiedBody . replace ( match , match . replace ( dependency . oldVersion , dependency . version ) )
22+ } )
23+ }
2224 }
2325
2426 // compile 'de.kevcodez:pubg-api-wrapper:1.0.0'
@@ -30,16 +32,16 @@ module.exports = {
3032 // id 'com.github.ben-manes.versions' version "0.21.0"
3133 const regexPluginVersionWithPrefix = new RegExp ( `${ dependency . group } ("|')(\\s+)?version(\\s+)?("|')${ oldVersion } ("|')` )
3234 const regexVersionWithPrefixMatches = regexPluginVersionWithPrefix . exec ( modifiedBody )
33- if ( regexVersionWithPrefixMatches ) {
35+ if ( regexVersionWithPrefixMatches && regexVersionWithPrefixMatches . length ) {
3436 regexVersionWithPrefixMatches . filter ( it => it . includes ( oldVersion ) ) . forEach ( match => {
3537 modifiedBody = modifiedBody . replace ( match , match . replace ( oldVersion , newVersion ) )
3638 } )
3739 }
38-
40+
3941 // compile group: 'de.kevcodez.pubg', name: 'pubg-api-wrapper', version: '0.8.1'
4042 const regexDependencyWithVersionPrefix = new RegExp ( `${ dependency . name } ('|"),(\\s+)?version:(\\s+)('|")${ dependency . oldVersion } ('|")` )
4143 const regexDependencyWithVersionPrefixMatches = regexDependencyWithVersionPrefix . exec ( modifiedBody )
42- if ( regexDependencyWithVersionPrefixMatches ) {
44+ if ( regexDependencyWithVersionPrefixMatches && regexDependencyWithVersionPrefixMatches . length ) {
4345 regexDependencyWithVersionPrefixMatches . filter ( it => it . includes ( oldVersion ) ) . forEach ( match => {
4446 modifiedBody = modifiedBody . replace ( match , match . replace ( oldVersion , newVersion ) )
4547 } )
0 commit comments