Open legobeat opened 3 months ago
Noticed that runExit
is also exposed as an undocumented instance method on the Cli
object returned from getCli
. Trying to call that instead yields a different error which makes me think we shouldn't be calling the instance method in the first place.
Self-service
Describe the bug
There seems to be no way to actually instrument the
runExit
function of@yarnpkg/cli
to run on anything else but the project inferred as entrypoint.The function has a
cwd
option but changing it seems to have no effect on where and how the command is run.To reproduce
There is a reproduction here: https://github.com/legobeat/yarnpkg-cli-test/blob/main/src/index.js
The results can be observed here.
The above repository contains two packages. While one resides under a subdirectory of the other, they are not related through a shared workspace but completely independent projects and packages.
The
foo
package has asayhello
package script which we want to call from theyarnpkg-cli-test
package.When attempting to call
runExit(['run', 'sayhello', { cwd: PATH_TO_foo })
, yarn does not recognize the script. Upon further investigation, it seems like any of thecwd
parameters are actually ineffective. The undocumentedselfPath
parameter appears to be intended to be used to override the path to theyarn
binary and unrelated.Is there something we're missing in order to be able to instrument execution of package scripts from arbitrary packagesd?
Environment
Additional context
No response