-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
How can I pass arguments to an nps command? #133
Comments
Try:
|
Nice I know now that I can do: nps "serve --env.platform=mobile" Putting the command in |
Thanks for using nps and filing an issue. If there's something that could be improved with the docs, please make a pull request: http://makeapullrequest.com |
@kentcdodds How can I do the same over npm e.g.:
Or do I have to use strictly nps now? Would be nice if the user could just rely on the defaulting behavior and just pass an argument at the very beginning. |
Hmmm.... That's a use case I hadn't considered. Most of the time you just make it a script (for example, call it |
Yes but if there is dynamic parameter, there is ability to pass without writing the full nps command path. I would be nice if I could run: npm start -- --env.platform=mobile
npm run build -- --env.platform=mobile without knowing the whole nps logic/path. It would be nice for Developers which have nothing to do with the build/runtime process. Totally get your |
Try: |
Doesn't solve my issue of being dynamic from the command line but it definitely solves some issues in the nps configuration file. |
Could you explain what you mean? |
The comment from @gunnx in this issue #101 is what I mean (or at least it describes the npm-script argument issue). There is no possibility to pass any kind of custom argument to nps without using the full nps command path and using nps directly. So I can't do this:
Because the double quote won't work as the nps command is behind the npm-script. And I can't do this:
When the targeted full command path is Summary:
But I think currently there isn't any solution for my problem. So it's more of a feature/enhancement to be considered in the future ;) |
Ok, let's talk about how to solve this problem. What do you mean by:
|
Let's do it ;) Imagine this configuration:
In the end I like to call I can do this currently by calling:
Now I would like to pass a custom argument to the command behind Suddenly, I can only do this by calling I can't do this because the behavior changed to:
|
@dweber019 Yeah there's a few occasions where I really miss the option to do this, I've got around it for most things by creating specific package-scripts entries to cover the common flags. It's where you want to pass dynamic values that it falls down, for example in my BDD test framework I have the option to running certain tags by passing them as a value but there are lots of tags and you can pass multiple tags or conditional tags, something thats just not realistic to be done via package-scripts. some examples:
I understand the reason to remove this was the confusion about whether to pass or not, would it be possible to have a new flag for |
@gunnx your suggestion about a new flag would be awesome. Btw. I could solve my npm run issue. "scripts": {
"start": "nps"
} I can pass arguments like So only the argument passing nps internally over defaulting behaviors is an issue. |
I'm really sorry that I'm struggling to understand the issue. Could you explain what you meant by:
What if we exposed an additional binary (
Would that solve the use-case? |
I don't think this will fix the defaulting issue. The custom argument should be passed from default command to default command until the final command is reached. |
I think that it would. If you used Would you like to try it out and makeapullrequest.com? :) |
I am running into the same issue. I will try to explain it a little differently and hopefully provide a solution. Script I am running Script processed as Ideally processed as Although extracting |
Yeah, I think we'd be safe to call that a patch. If you'd like to implement that, I'd happily accept 👍 |
This should be closable. Only potential dependency would be documentation. |
Whoops, forgot to ask you to document that in your PR. Could you do that really quick? Then we can close this. Thanks @kwelch! |
Good call 👍 |
I want this too, use case is local dev using |
This is exactly what I'm looking for. My primary use case is using it for isolating specific tests: I see a solution was merged, but I'm looking for the documentation because I can't seem to get it to work the way I expect. |
@GarthDB Looks like it was merged but hasn't been published yet |
All my packages are automatically published. If it hasn't been published then something went wrong with the build. |
To clarify on usage, here is an example
Example usage: (without "--")
Example usage: (with "--") > [email protected] start C:\Test
> nps "myScript -- myArg"
nps is executing `myScript` : echo Hi -- myArg
Hi -- myArg |
nps
version: latestnode
version: lastestnpm
version: lastestThe command executed:
The output:
You provided one or more invalid flags: env Did you forget to put your command in quotes?
Or it just runs without applying the argument.
Problem description:
How can I pass arguments to an nps command?
Before I was using npm scripts and there I could pass arguments form the command line like https://docs.npmjs.com/cli/run-script.
This is not possible or at least not documented.
Use case:
I like to provide something dynamically to the command. E.g. the name of a configuration file.
I don't like to configure for each dynamic option an nps command and in addition, to be user friendly, I would also have to configure all the npm scripts for each nps command.
Suggested solution:
Add the same option as npm-script does to support passing arguments from the command line.
The text was updated successfully, but these errors were encountered: