Skip to content

Commit 241bbc6

Browse files
committed
Output stderr from commands, if they fail
1 parent 1350ca7 commit 241bbc6

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

index.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ if (!gradleCommand) {
4545
}
4646

4747
if (!gradleCommand) {
48-
console.log('Unable to find Gradle Wrapper or Gradle CLI.'.red)
48+
console.log('Unable to find Gradle Wrapper or Gradle CLI.'.bgRed)
4949
return
5050
}
5151

52-
console.log('Checking for upgrades...')
52+
console.log('Checking for upgrades...\n')
5353

5454
const gduArgs = ['dependencyUpdates', '-DoutputFormatter=json', '-DoutputDir=build/dependencyUpdates']
5555
const gduResolution = argv.resolution
@@ -60,15 +60,19 @@ if (gduResolution) {
6060
const gdu = spawnSync(gradleCommand, gduArgs);
6161

6262
if (gdu.status !== 0) {
63-
console.log(`Error executing gradle dependency updates (StatusCode=${gdu.status}), have you installed the gradle versions plugin?`.red)
64-
console.log('https://github.com/ben-manes/gradle-versions-plugin\n')
65-
console.log(`Plugins block`)
63+
console.log(`Error executing gradle dependency updates (StatusCode=${gdu.status})`.bgRed)
64+
65+
console.log(gdu.stderr.toString().red)
66+
67+
console.log(`\nIn case you haven't installed the gradle-versions-plugin (https://github.com/ben-manes/gradle-versions-plugin), put one of the following in your gradle build file:\n`)
68+
69+
console.log(`Either Plugins block`)
6670
console.log(`
6771
plugins {
6872
id "com.github.ben-manes.versions" version "0.24.0"
6973
}\n`.green)
7074

71-
console.log('buildscript block')
75+
console.log('or buildscript block')
7276

7377
console.log(`
7478
apply plugin: "com.github.ben-manes.versions"
@@ -130,7 +134,8 @@ if (gdu.status !== 0) {
130134
const upgradeGradleWrapper = spawnSync(gradleCommand, ['wrapper', '--gradle-version=' + latestGradleRelease]);
131135

132136
if (upgradeGradleWrapper.status !== 0) {
133-
console.log(`Error upgrading gradle wrapper (StatusCode=${upgradeGradleWrapper.status}).`)
137+
console.log(`Error upgrading gradle wrapper (StatusCode=${upgradeGradleWrapper.status}).`.bgRed)
138+
console.log(upgradeGradleWrapper.stderr.toString().red)
134139
return
135140
}
136141
}
@@ -143,7 +148,7 @@ if (gdu.status !== 0) {
143148
})
144149

145150
fs.writeFile('build.gradle', buildFileAsString, 'utf8', function (err) {
146-
if (err) return console.log(`Unable to write gradle build file.\n${err}`.red);
151+
if (err) return console.log(`Unable to write gradle build file.\n${err}`.bgRed);
147152
});
148153

149154
});

0 commit comments

Comments
 (0)