corepack
corepack copied to clipboard
Feature request: corepack exec
Hi,
This feature request is not exactly the same than the one mentioned in #57. As introduced in the docs here, command corepack <binary name>[@<version>] [... args]
allows to execute a package manager of our choice with custom arguments. This command checks whether the local project is configured for the given package manager.
I personnally would be interested with a command such as corepack exec [... args]
(exec
may not be the most relevant term however), that would take the exact release set in the packageManager
property. I guess it is possible because in the command above, I assume corepack parses property packageManager
in the package.json
file to verify consistency with <binary name>
.
Thus, I could run a command of the package manager whatever it is, and without repeating the binary name. This may be useful in writing plugins/extensions for build tools such as Maven, Gradle, acting as a bridge to launch npm/pnpm/yarn commands, without having to parse the package.json
file and discover the package manager.
Thanks in advance for your comments. BR
Can you give an example of what you might exec?
Are you thinking something like corepack exec run build
which would then execute npm run build
/ yarn run build
?
Or are you thinking corepack exec install
to execute npm install
/ yarn install
?
I'm not sure how this is different then https://github.com/nodejs/corepack/issues/57#issuecomment-920311561
Issue #57 deals explicitly with <packageManager> run
commands, and having the package manager automatically added in the PATH for recursion. I didn't want to pollute the original request.
Both examples you introduced corepack exec run build
and corepack exec install
are typical UC I'm interested in. I don't see the subtleness for corepack itself between the 2 examples, Am I missing something?
My UC: I'm working on this Gradle plugin, that allows integrating a build of a Node.js-based project into a Gradle build. Actually, if the plugin needs to run a command of the selected package manager (I mean the one defined in the package.json
file), it must repeat the binary name with corepack <binary name>[@<version>] [... args]
. This is just redundant and it requires some additional work whereas corepack knows the selected package manager. That's why I'd like such shortcut.
Does it make sense?