Skip to content
Draft
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
11 changes: 9 additions & 2 deletions packages/cli-kit/src/public/node/custom-oclif-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,16 @@ export class ShopifyConfig extends Config {
commandClass.id = id
// eslint-disable-next-line @typescript-eslint/no-explicit-any
commandClass.plugin = cmd.plugin ?? (this as any).rootPlugin
await this.runHook('prerun', {argv, Command: commandClass})
// Execute the command first — give it exclusive CPU time.
const result = (await commandClass.run(argv, this)) as T
await this.runHook('postrun', {argv, Command: commandClass, result})
// Fire prerun + postrun AFTER command completes. Both are fire-and-forget.
// Analytics is best-effort; process.exit(0) in bootstrap may terminate
// before these complete, which is fine.
// eslint-disable-next-line no-void
void this.runHook('prerun', {argv, Command: commandClass}).then(() => {
// eslint-disable-next-line no-void
void this.runHook('postrun', {argv, Command: commandClass, result})
})
return result
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ async function runShopifyCLI({development}: RunShopifyCLIOptions) {
development,
lazyCommandLoader: loadCommand,
})
// Force exit after command completes. Pending network requests (analytics,
// version checks) are best-effort and shouldn't delay the user.
process.exit(0)
}

export default runShopifyCLI
Loading