Skip to content
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
9 changes: 6 additions & 3 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ program
program.option('--no-color', 'Disable color output');

// Apply global flags and telemetry before any command runs
program.hook('preAction', async (thisCommand) => {
// Note: preAction receives (thisCommand, actionCommand) where:
// - thisCommand: the command where hook was added (root program)
// - actionCommand: the command actually being executed (subcommand)
program.hook('preAction', async (thisCommand, actionCommand) => {
const opts = thisCommand.opts();
if (opts.color === false) {
process.env.NO_COLOR = '1';
Expand All @@ -59,8 +62,8 @@ program.hook('preAction', async (thisCommand) => {
// Show first-run telemetry notice (if not seen)
await maybeShowTelemetryNotice();

// Track command execution
const commandPath = getCommandPath(thisCommand);
// Track command execution (use actionCommand to get the actual subcommand)
const commandPath = getCommandPath(actionCommand);
await trackCommand(commandPath, version);
});

Expand Down
Loading