-
Notifications
You must be signed in to change notification settings - Fork 238
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
[RRFC] "npm pkg get <value> --raw" to get raw unquoted values for further use in scripts #634
Comments
This feature makes sense to me. |
This sounds like a good idea! I just believe that what we want here is to add support to Just to add some background, there are basically 3 different types of output that the npm cli supports:
That said, maybe this is too small of a feature to afford a full RFC. I can see this being an realatively-easy-to-merge contribution in case someone from the community submits a PR, or else it should be a backlogged item for the npm cli team. |
parseable and a PR sounds great to me :-) hopefully the npm cli team can weigh in. |
very much +1 to parsable |
Looks good. I'm +1 to |
Tracking as a feature enhancement in the CLI here: npm/cli#5508 |
Current behavior
One of the most popular use cases for pkg get command is getting values for other scripts as variables. However currently it's returning the value with quotes:
The current solution is to use it in a pipe and remove quotes somehow with sed or jq.:
Example:
However it comes with some cons:
Desired Behaviour
To introduce --raw/-r flag for npm pkg get command
Thus, for the following command we will expect the raw value:
So the previous example would look like :
References
It's a simple case but you can see how much discussion about this topic:
https://gist.github.com/DarrenN/8c6a5b969481725a4413
https://stackoverflow.com/questions/9153571/is-there-a-way-to-get-version-from-package-json-in-nodejs-code
The text was updated successfully, but these errors were encountered: