nodejs / corepack

Zero-runtime-dependency package acting as bridge between Node projects and their package managers
MIT License
2.52k stars 165 forks source link

fix!: call `executePackageManagerRequest` directly #430

Closed merceyz closed 5 months ago

merceyz commented 6 months ago

Calling executePackageManagerRequest directly instead of through Clipanion lets Node.js handle printing errors which results in the cause property being printed correctly.

Ref https://github.com/nodejs/corepack/issues/458 and others like it. Ref https://github.com/nodejs/corepack/pull/425#issuecomment-2000189938

Depends on

Performance is roughly the same

$ hyperfine -w 5 "node ./dist-before/yarn.js -v" "node ./dist-after/yarn.js -v"
Benchmark 1: node ./dist-before/yarn.js -v
  Time (mean ± σ):     188.0 ms ±   9.9 ms    [User: 204.5 ms, System: 22.3 ms]
  Range (min … max):   179.0 ms … 222.1 ms    16 runs

Benchmark 2: node ./dist-after/yarn.js -v
  Time (mean ± σ):     186.5 ms ±   7.8 ms    [User: 202.5 ms, System: 22.4 ms]
  Range (min … max):   178.1 ms … 204.9 ms    16 runs

Summary
  node ./dist-after/yarn.js -v ran
    1.01 ± 0.07 times faster than node ./dist-before/yarn.js -v

BREAKING CHANGE: Some errors are now printed to stderr instead of stdout