unjs / nypm

🌈 Unified Package Manager for Node.js and Bun
MIT License
437 stars 13 forks source link

`workspace` option is not actually working when using PNPM #123

Closed AndreaPontrandolfo closed 1 week ago

AndreaPontrandolfo commented 3 months ago

Environment

nypm: v0.3.8 node: v20.10.0 pnpm: v8.14.0

Reproduction

placeholder

Describe the bug

Pnpm requires --filter arg to install a dependency into a specified workspace. I saw in the source code that you use the -F argument, which is correct. However, it doesn't seem to be working, because the passed arg to execa is actually --dir, which is incorrect (pnpmdoesn't understand it).

Additional context

No response

Logs

~ executeCommand ~ args: [
  'add',
  '--dir',
  'cli-playground',
  '-D',
  'eslint@latest',
  'eslint-define-config@latest',
  'eslint-config-sheriff@latest'
]
~ executeCommand ~ command: pnpm
~ executeCommand ~ execaArgs: [
  'corepack',
  [
    'pnpm',
    'add',
    '--dir',
    'cli-playground',
    '-D',
    'eslint@latest',
    'eslint-define-config@latest',
    'eslint-config-sheriff@latest'
  ]
]
AndreaPontrandolfo commented 3 months ago

I'll try to come up with a repro ASAP.

AndreaPontrandolfo commented 3 months ago

Is the repro needed? Can you provide guidance on that?

AndreaPontrandolfo commented 2 months ago

So, i analyzed the situation again, and actually i need to rectify. The problem is exactly on this line return workspacePkg ? ["--dir", workspacePkg] : ["--workspace-root"];. Yes, PNPM understand the "dir" argument, but it's actually incorrect for reaching a workspace package. The right argument is filter. I'm gonna patch-package this for my own project, for now. Do you plan to fix this? I don't think this is the intended behaviour.