@@ -45,15 +45,15 @@ const {
45
45
46
46
if ( ! gradleCommand ) {
47
47
console . log ( 'Unable to find Gradle Wrapper or Gradle CLI.' . bgRed )
48
- return
48
+ process . exit ( )
49
49
}
50
50
51
51
const externalFiles = argv [ 'external-file' ] ;
52
- const buildFiles = getBuildFiles ( externalFiles )
53
- debugLog ( ' Build Files:\n' + buildFiles . join ( '\n' ) )
52
+ const buildFiles = getBuildFiles ( externalFiles , debugLog )
53
+ debugLog ( ` Build Files:\n ${ buildFiles . join ( '\n' ) } ` )
54
54
if ( ! buildFiles . length ) {
55
55
console . log ( 'Unable to find build.gradle, build.gradle.kts or external build file.' . bgRed )
56
- return
56
+ process . exit ( )
57
57
}
58
58
59
59
exports . debugLog = debugLog ;
@@ -76,6 +76,10 @@ async function executeCommandAndWaitForExitCode(command, args) {
76
76
commandExitCode = code
77
77
} )
78
78
79
+ child . on ( 'exit' , ( code ) => {
80
+ commandExitCode = code
81
+ } )
82
+
79
83
while ( commandExitCode === undefined ) {
80
84
debugLog ( 'Waiting for command to finish' )
81
85
await new Promise ( resolve => setTimeout ( resolve , 500 ) ) ;
@@ -99,16 +103,14 @@ async function executeCommandAndWaitForExitCode(command, args) {
99
103
100
104
if ( gradleDependencyUpdateProcessExitCode !== 0 ) {
101
105
informUserAboutInstallingUpdatePlugin ( gradleDependencyUpdateProcessExitCode ) ;
102
- return
106
+ process . exit ( )
103
107
}
104
108
105
109
if ( ! buildFiles . length ) {
106
110
console . log ( 'Unable to find build.gradle, build.gradle.kts or external build file.' . bgRed ) ;
107
- return ;
111
+ process . exit ( )
108
112
}
109
113
110
- debugLog ( 'Build files ' + buildFiles ) ;
111
-
112
114
debugLog ( `Reading JSON report file\n` )
113
115
114
116
const dependencyUpdates = findOutdatedDependencies ( ) ;
@@ -123,7 +125,7 @@ async function executeCommandAndWaitForExitCode(command, args) {
123
125
124
126
if ( ! choices . length ) {
125
127
console . log ( 'Everything up to date.' )
126
- return
128
+ process . exit ( )
127
129
}
128
130
129
131
const response = await prompts ( {
@@ -134,11 +136,11 @@ async function executeCommandAndWaitForExitCode(command, args) {
134
136
} ) ;
135
137
136
138
if ( ! response . upgrades || ! response . upgrades . length ) {
137
- console . log ( 'No upgrades select ' )
138
- return
139
+ console . log ( 'No upgrades selected ' )
140
+ process . exit ( )
139
141
}
140
142
141
- if ( response . upgrades . some ( it => it === 'gradle' ) ) {
143
+ if ( latestGradleRelease && response . upgrades . some ( it => it === 'gradle' ) ) {
142
144
console . log ( 'Upgrading gradle wrapper' )
143
145
const upgradeArgs = [ 'wrapper' , '--gradle-version=' + latestGradleRelease ]
144
146
@@ -148,7 +150,7 @@ async function executeCommandAndWaitForExitCode(command, args) {
148
150
if ( upgradeGradleWrapperExitCode !== 0 ) {
149
151
console . log ( `Error upgrading gradle wrapper (StatusCode=${ upgradeGradleWrapper . status } ).` . bgRed )
150
152
console . log ( upgradeGradleWrapper . stderr . toString ( ) . red )
151
- return
153
+ process . exit ( )
152
154
}
153
155
}
154
156
@@ -192,7 +194,7 @@ async function executeCommandAndWaitForExitCode(command, args) {
192
194
writeFileSync ( buildFile , modifiedContent , 'utf8' ) ;
193
195
} catch ( err ) {
194
196
console . log ( `Unable to write gradle build file.\n${ err } ` . bgRed ) ;
195
- return
197
+ process . exit ( )
196
198
}
197
199
198
200
} , buildFileContentMap )
@@ -238,9 +240,10 @@ function buildUpgradeChoicesForUser(outdatedDependencies, dependencyUpdates) {
238
240
choices . sort ( ( a , b ) => a . title . localeCompare ( b . title ) ) ;
239
241
debugLog ( `Choices\n${ JSON . stringify ( choices ) } \n\n` ) ;
240
242
243
+ let latestGradleRelease
241
244
if ( dependencyUpdates . gradle ) {
242
245
let currentGradleRelease = dependencyUpdates . gradle . running . version ;
243
- let latestGradleRelease = dependencyUpdates . gradle . current . version ;
246
+ latestGradleRelease = dependencyUpdates . gradle . current . version ;
244
247
if ( gradleWrapper && currentGradleRelease !== latestGradleRelease ) {
245
248
choices . unshift ( {
246
249
title : `Gradle - ${ currentGradleRelease } => ${ latestGradleRelease } ` ,
0 commit comments