Skip to content

Feature: npm pkg get <value> --raw #5508

@ThePlenkov

Description

@ThePlenkov

Problem
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:

npm pkg get version 
"4.12.2"

The current solution is to use it in a pipe and remove quotes somehow with sed or jq. It's ok, but this solution si not cross-platform or requires additional packages installation.

Suggestion
To introduce --raw/-r flag for npm pkg get command
Thus, for the following command we will expect the raw value:

npm pkg get version --raw
4.12.2

What do you think? 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancementnew feature or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions