Skip to content

Commit ebffbc9

Browse files
committed
#4 Debug logging / Relative file path for wrapper
1 parent 0b9826c commit ebffbc9

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

gradleCommand.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
const {
22
spawnSync
33
} = require('child_process');
4+
const {join} = require('path')
45

5-
function determineGradleCommand() {
6+
function determineGradleCommand(debugLog) {
67
let gradleCommand = null
78
let gradleWrapper = false
9+
debugLog('Determining gradle command')
810
try {
911
const isWindows = process.platform === 'win32'
12+
debugLog('isWindows: ' + isWindows)
1013
const gradleWrapperFile = isWindows ? 'gradlew.bat' : 'gradlew'
11-
if (existsSync(gradleWrapperFile)) {
14+
15+
const gradleWrapperFilePath = join('./', gradleWrapperFile)
16+
17+
debugLog(`Checking if wrapper file ${gradleWrapperFilePath} exists`)
18+
if (existsSync(gradleWrapperFilePath)) {
19+
debugLog('Wrapper file exists')
1220
gradleCommand = (isWindows ? '' : './') + gradleWrapperFile
1321
gradleWrapper = true
22+
} else {
23+
debugLog('Wrapper file not found')
1424
}
1525
} catch (err) {}
1626

@@ -21,6 +31,8 @@ function determineGradleCommand() {
2131
}
2232
}
2333

34+
debugLog(`Determined gradle command: ${gradleCommand}, wrapper: ${gradleWrapper}`)
35+
2436
return {
2537
gradleCommand,
2638
gradleWrapper

index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ const {
77
argv
88
} = require('./args')
99

10+
function debugLog(message) {
11+
if (argv.debug) {
12+
console.log(message.blue)
13+
}
14+
}
15+
1016
const prompts = require('prompts');
1117
const {
1218
existsSync,
@@ -37,7 +43,7 @@ const {
3743
const {
3844
gradleCommand,
3945
gradleWrapper
40-
} = determineGradleCommand()
46+
} = determineGradleCommand(debugLog)
4147

4248
if (!gradleCommand) {
4349
console.log('Unable to find Gradle Wrapper or Gradle CLI.'.bgRed)
@@ -271,8 +277,3 @@ function informUserAboutInstallingUpdatePlugin() {
271277
`.green);
272278
}
273279

274-
function debugLog(message) {
275-
if (argv.debug) {
276-
console.log(message.blue)
277-
}
278-
}

0 commit comments

Comments
 (0)