Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): move version logging earlier in CLI to allow -v, --version #5425

Merged
merged 1 commit into from
Mar 4, 2024
Merged
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
15 changes: 10 additions & 5 deletions src/cli/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ export const run = async (init: d.CliInitOptions) => {
sys.applyGlobalPatch(sys.getCurrentDirectory());
}

if ((task && task === 'version') || flags.version) {
// we need to load the compiler here to get the version, but we don't
// want to load it in the case that we're going to just log the help
// message and then exit below (if there's no `task` defined) so we load
// it just within our `if` scope here.
const coreCompiler = await loadCoreCompiler(sys);
console.log(coreCompiler.version);
return;
}

if (!task || task === 'help' || flags.help) {
await taskHelp(createConfigFlags({ task: 'help', args }), logger, sys);

Expand All @@ -53,11 +63,6 @@ export const run = async (init: d.CliInitOptions) => {

const coreCompiler = await loadCoreCompiler(sys);

if (task === 'version' || flags.version) {
console.log(coreCompiler.version);
return;
}

startupLogVersion(logger, task, coreCompiler);

loadedCompilerLog(sys, logger, flags, coreCompiler);
Expand Down
Loading