Skip to content

Commit

Permalink
fix: the start time on command throw
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhq committed May 11, 2023
1 parent d189e19 commit 4c15109
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions core/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ ${renderCommands(commands)}
let garden: Garden
let result: CommandResult<any> = {}
let analytics: AnalyticsHandler | undefined = undefined
let commandStartTime: Date | undefined = undefined

const prepareParams = {
log,
Expand Down Expand Up @@ -476,7 +477,7 @@ ${renderCommands(commands)}

await checkForStaticDir()

const commandStartTime = new Date()
commandStartTime = new Date()

// Check if the command is protected and ask for confirmation to proceed if production flag is "true".
if (await command.isAllowedToRun(garden, log, parsedOpts)) {
Expand Down Expand Up @@ -531,8 +532,13 @@ ${renderCommands(commands)}
)
}

// Track the result of the command run
analytics?.trackCommandResult(command.getFullName(), commandIteration, [err], new Date(), result.exitCode)
analytics?.trackCommandResult(
command.getFullName(),
commandIteration,
[err],
commandStartTime || new Date(),
result.exitCode
)

// flush analytics early since when we throw the instance is not returned
await analytics?.flush()
Expand Down

0 comments on commit 4c15109

Please sign in to comment.