Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/commands/manifest/convert_gradle_to_maven.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export async function convertGradleToMaven(
) {
// Lazily access constants.spinner.
const { spinner } = constants

const rbin = path.resolve(bin)
const rtarget = path.resolve(target)

Expand All @@ -29,10 +30,6 @@ export async function convertGradleToMaven(
logger.groupEnd()
}

spinner.start(
`Converting gradle to maven from \`${bin}\` on \`${target}\`...`
)

try {
// Run sbt with the init script we provide which should yield zero or more pom files.
// We have to figure out where to store those pom files such that we can upload them and predict them through the GitHub API.
Expand All @@ -43,8 +40,13 @@ export async function convertGradleToMaven(
const commandArgs = ['--init-script', initLocation, ...gradleOpts, 'pom']

if (verbose) {
spinner.log('[VERBOSE] Executing:', bin, commandArgs)
logger.log('[VERBOSE] Executing:', bin, commandArgs)
}

spinner.start(
`Converting gradle to maven from \`${bin}\` on \`${target}\`...`
)

const output = await spawn(bin, commandArgs, {
cwd: target || '.'
})
Expand All @@ -64,7 +66,8 @@ export async function convertGradleToMaven(
logger.error(output.stderr)
logger.groupEnd()
}
process.exit(1)
process.exitCode = 1
return
}
logger.success('Executed gradle successfully')
logger.log('Reported exports:')
Expand Down Expand Up @@ -104,8 +107,7 @@ export async function convertGradleToMaven(
// spinner.successAndStop(`OK. File should be available in \`${out}\``)
// }
} catch (e: any) {
spinner.stop()
logger.error(
spinner.errorAndStop(
'There was an unexpected error while running this' +
(verbose ? '' : ' (use --verbose for details)')
)
Expand All @@ -114,6 +116,8 @@ export async function convertGradleToMaven(
logger.log(e)
logger.groupEnd()
}
process.exit(1)
process.exitCode = 1
} finally {
spinner.stop()
}
}
20 changes: 12 additions & 8 deletions src/commands/manifest/convert_sbt_to_maven.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export async function convertSbtToMaven(
logger.groupEnd()
}

spinner.start(`Converting sbt to maven from \`${bin}\` on \`${target}\`...`)

try {
spinner.start(`Converting sbt to maven from \`${bin}\` on \`${target}\`...`)

// Run sbt with the init script we provide which should yield zero or more
// pom files. We have to figure out where to store those pom files such that
// we can upload them and predict them through the GitHub API. We could do a
Expand All @@ -59,7 +59,8 @@ export async function convertSbtToMaven(
logger.error(output.stderr)
logger.groupEnd()
}
process.exit(1)
process.exitCode = 1
return
}
const poms: string[] = []
output.stdout.replace(/Wrote (.*?.pom)\n/g, (_all: string, fn: string) => {
Expand All @@ -70,7 +71,8 @@ export async function convertSbtToMaven(
logger.error(
'There were no errors from sbt but it seems to not have generated any poms either'
)
process.exit(1)
process.exitCode = 1
return
}
// Move the pom file to ...? initial cwd? loc will be an absolute path, or dump to stdout
// TODO: what to do with multiple output files? Do we want to dump them to stdout? Raw or with separators or ?
Expand All @@ -86,7 +88,8 @@ export async function convertSbtToMaven(
)
poms.forEach(fn => logger.error('-', fn))
logger.error('Exiting now...')
process.exit(1)
process.exitCode = 1
return
} else {
// if (verbose) {
// logger.log(
Expand All @@ -102,8 +105,7 @@ export async function convertSbtToMaven(
logger.success(`OK`)
}
} catch (e: any) {
spinner.stop()
logger.error(
spinner?.errorAndStop(
'There was an unexpected error while running this' +
(verbose ? '' : ' (use --verbose for details)')
)
Expand All @@ -112,6 +114,8 @@ export async function convertSbtToMaven(
logger.log(e)
logger.groupEnd()
}
process.exit(1)
process.exitCode = 1
} finally {
spinner.stop()
}
}
Loading