@@ -16,9 +16,11 @@ module.exports = {
16
16
const regexVariableDefinition = new RegExp ( `(${ variableName } (\\s+)?=(\\s+)?('|")${ oldVersion } ('|"))` , "ig" )
17
17
const regexVariableDefinitionMatches = regexVariableDefinition . exec ( modifiedBody )
18
18
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
+ }
22
24
}
23
25
24
26
// compile 'de.kevcodez:pubg-api-wrapper:1.0.0'
@@ -30,16 +32,16 @@ module.exports = {
30
32
// id 'com.github.ben-manes.versions' version "0.21.0"
31
33
const regexPluginVersionWithPrefix = new RegExp ( `${ dependency . group } ("|')(\\s+)?version(\\s+)?("|')${ oldVersion } ("|')` )
32
34
const regexVersionWithPrefixMatches = regexPluginVersionWithPrefix . exec ( modifiedBody )
33
- if ( regexVersionWithPrefixMatches ) {
35
+ if ( regexVersionWithPrefixMatches && regexVersionWithPrefixMatches . length ) {
34
36
regexVersionWithPrefixMatches . filter ( it => it . includes ( oldVersion ) ) . forEach ( match => {
35
37
modifiedBody = modifiedBody . replace ( match , match . replace ( oldVersion , newVersion ) )
36
38
} )
37
39
}
38
-
40
+
39
41
// compile group: 'de.kevcodez.pubg', name: 'pubg-api-wrapper', version: '0.8.1'
40
42
const regexDependencyWithVersionPrefix = new RegExp ( `${ dependency . name } ('|"),(\\s+)?version:(\\s+)('|")${ dependency . oldVersion } ('|")` )
41
43
const regexDependencyWithVersionPrefixMatches = regexDependencyWithVersionPrefix . exec ( modifiedBody )
42
- if ( regexDependencyWithVersionPrefixMatches ) {
44
+ if ( regexDependencyWithVersionPrefixMatches && regexDependencyWithVersionPrefixMatches . length ) {
43
45
regexDependencyWithVersionPrefixMatches . filter ( it => it . includes ( oldVersion ) ) . forEach ( match => {
44
46
modifiedBody = modifiedBody . replace ( match , match . replace ( oldVersion , newVersion ) )
45
47
} )
0 commit comments