diff --git a/src/cli/run.ts b/src/cli/run.ts index 39d4fd4de0f..1c677bdca17 100644 --- a/src/cli/run.ts +++ b/src/cli/run.ts @@ -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); @@ -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);