knip icon indicating copy to clipboard operation
knip copied to clipboard

Script parser doesn't account for optional "run" when running scripts

Open jgoux opened this issue 1 year ago • 1 comments

It seems like the script parser doesn't detect scripts when omitting the run keyword for package managers like pnpm and yarn.

In the following Github Action example, the start:server script is reported as an unlisted binary:

- name: Run dev API in the background background
        run: |
          pnpm -F @snaplet/seed start:server &
          npx --yes wait-on -d 5000 -i 2000 -t 20000 http://localhost:3000 --log --verbose

This is fixable by explicitly using run like this: pnpm -F @snaplet/seed run start:server &.

But it would be cool if the script parser works without it. 😄

jgoux avatar Mar 20 '24 09:03 jgoux

This issue is specific to monorepos. Knip should not match start:server in the current workspace, but in -F this one. Unfortunately this isn't trivial given how Knip currently handles this.

In general Knip should handle either pnpm start:server or pnpm run start:server fine, but does not work as expected when using the -F argument.

webpro avatar Mar 20 '24 15:03 webpro

Closing this as "wontfix".

webpro avatar Jul 12 '24 06:07 webpro