Skip to content

fix(cli): fix --no-tty flag not being recognized in init command#783

Merged
pyramation merged 1 commit intomainfrom
fix/no-tty-flag-parsing
Mar 6, 2026
Merged

fix(cli): fix --no-tty flag not being recognized in init command#783
pyramation merged 1 commit intomainfrom
fix/no-tty-flag-parsing

Conversation

@theothersideofgod
Copy link
Contributor

Problem

The --no-tty flag was not working when running pgpm init commands. Users expecting non-interactive mode with --no-tty would still get interactive prompts.

Root Cause

minimist parses --no-<name> flags differently than expected:

  • --no-tty is parsed as { tty: false }, NOT { 'no-tty': true }

The original code checked for argv['no-tty'], which would always be undefined, causing the flag to be silently ignored.

Solution

Added argv.tty === false check to correctly detect the --no-tty flag:

// Before (bug)
const noTty = Boolean(argv.noTty || argv['no-tty'] || process.env.CI);

// After (fixed)
const noTty = Boolean(argv.noTty || argv['no-tty'] || argv.tty === false || process.env.CI);

Files Changed

  • pgpm/cli/src/commands/init/index.ts (2 occurrences)
  • pgpm/cli/src/commands/init/workspace.ts (1 occurrence)

## Problem
The `--no-tty` flag was not working when running `pgpm init` commands.
Users expecting non-interactive mode with `--no-tty` would still get
interactive prompts.

## Root Cause
minimist parses `--no-<name>` flags differently than expected:
- `--no-tty` is parsed as `{ tty: false }`, NOT `{ 'no-tty': true }`

The original code checked for `argv['no-tty']`, which would always be
`undefined`, causing the flag to be silently ignored.

## Solution
Added `argv.tty === false` check to correctly detect the `--no-tty` flag:

```typescript
// Before (bug)
const noTty = Boolean(argv.noTty || argv['no-tty'] || process.env.CI);

// After (fixed)
const noTty = Boolean(argv.noTty || argv['no-tty'] || argv.tty === false || process.env.CI);
```

## Files Changed
- pgpm/cli/src/commands/init/index.ts (2 occurrences)
- pgpm/cli/src/commands/init/workspace.ts (1 occurrence)
@pyramation pyramation merged commit b70ee76 into main Mar 6, 2026
42 checks passed
@pyramation pyramation deleted the fix/no-tty-flag-parsing branch March 6, 2026 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants