Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: corepack exec #148

Open
v1nc3n4 opened this issue Jul 20, 2022 · 2 comments
Open

Feature request: corepack exec #148

v1nc3n4 opened this issue Jul 20, 2022 · 2 comments

Comments

@v1nc3n4
Copy link

v1nc3n4 commented Jul 20, 2022

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

@styfle
Copy link
Member

styfle commented Jul 20, 2022

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 #57 (comment)

@v1nc3n4
Copy link
Author

v1nc3n4 commented Jul 20, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants