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

Question: How to pass additional arguments to npm task via Gradle command line? #262

Open
IvanPizhenko opened this issue Feb 21, 2023 · 1 comment

Comments

@IvanPizhenko
Copy link

IvanPizhenko commented Feb 21, 2023

Assume in my package.json I have a task named "xxx".
Using npm itself, I can run it as follows: npm run xxx.
I also can run it with additional arguments in the following way: npm run xxx -- more arguments for xxx.
When I run this task using node plugin for Gradle, I can run it using ./gradlew npm_run_xxx.
But is there a way to pass those additional arguments to the npm task, like I've done above with npm right on the Gradle command line?

@IvanPizhenko IvanPizhenko changed the title Question: How to pass additional arguments to node task via gradle command line? Question: How to pass additional arguments to npm task via Gradle command line? Feb 21, 2023
@deepy
Copy link
Member

deepy commented Feb 22, 2023

Do you need these to be generic or is there a different set of them?
If you've got a set of them you can do something like the following for each:

tasks.register('myNpmTask', NpmTask) {
  args = ['run', 'task', 'args']
  inputs.dir('src') // Remember to declare inputs and outputs
  outputs.dir('dist')
}

Otherwise if you need it to be dynamic you can either subclass NpmTask and add a command-line argument or make use of project properties in the args

But this project supplying a generalized NpmRunTask might make sense here 🤔

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