Knip doesn't parse arguments of yarn run --top-level
correctly
#739
Labels
bug
Something isn't working
yarn run --top-level
correctly
#739
Reproduction url
Sandbox
Description of the issue
In a monorepo setting, a workspace script invoking a top-level script which takes positional parameters gets these parameters incorrectly interpreted as scripts (and reported) by knip
Top-level package.json:
Here, the
echo
script just calls theecho
shell command, which takes extra parameters on the command line.Workspace (
packages/shared
) package.json:This uses the
--top-level
flag which seems to not exist in yarn 1. It simply calls the top-level script, providing a parameter to it.When running (from the toplevel)
yarn workspace @monorepo/shared run foo
, or (from the workspace directory)yarn foo
, I get the correct behaviour (displayhello
in the terminal).When running
yarn knip
, I get:So, it seems that knip is interpreting the command as running
echo
andhello
scripts.Adding a
hello
script inside the package does remove the reporting. Adding one at toplevel doesn't.This may be related to #735 but I believe it is different.
I was not able to reproduce this in a basic (single workspace) setting; Without the
--top-level
option (and using anecho
script in the workspace),hello
is not reported, so the option may have something to do with it.Somehow, removing the
echo
script from the top-level is not reported. Maybe knip interpretesyarn run --top-level echo hello
as being an option--top-level echo
and calling scripthello
(instead of option--top-level
and calling scriptecho
with parameterhello
).The text was updated successfully, but these errors were encountered: