Files
a85c8f719f fix(cli): honor directory flags in dlx and create (#17479)
`-C/--dir` is documented as "run as if pnpm was started in <path>", but
dlx, pnx, and create spawned the executed command in the process cwd in
both CLIs, ignoring `--dir` and `--workspace-root`.

pnpm v12: dispatch dlx and create with the CLI-directory anchor
(`cli_dir`), which is the `--dir`/`-w` directory when one was given on the
command line and the invocation directory otherwise. SpawnEnv borrows
that path for the spawn cwd.

pnpm v11: the dlx handler spawns in `cliOptions.dir ?? process.cwd()`,
matching single-project exec. `-w` already writes the workspace root into
`cliOptions.dir`. create delegates to the dlx handler with its options
unchanged.

Tests:
- Rust: the bin's cwd, forwarded arguments, and output location for
  dlx and create, with `-C`, `-w`, and no flag, in direct and shell mode.
- v11 e2e: dlx with `-C`, `-w`, and no flag.
- v11 unit: create forwards `cliOptions` to the dlx handler.

---------

Signed-off-by: BayLee4 <63376748+BayLee4@users.noreply.github.com>
Co-authored-by: Zoltan Kochan <z@kochan.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 11:17:04 +01:00
..