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

docs: show complex object interactions in npm pkg #4847

Merged
merged 1 commit into from
May 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/content/commands/npm-pkg.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ Returned values are always in **json** format.
npm pkg get contributors[0].email
```

For complex fields you can also name a property in square brackets
to specifically select a child field. This is especially helpful
with the exports object:

```bash
npm pkg get "exports[.].require"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"text indices" suggests like, 0, 1, 2, etc. is . special?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No '.' is a valid ascii character hence "text"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right but "indices" are only numeric. if it's object properties then "properties" might be a better word?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    For complex fields you can also name a property in square brackets
    to specifically select a child field. This is especially helpful
    with the exports object:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds great to me, thanks!

```

* `npm pkg set <field>=<value>`

Sets a `value` in your `package.json` based on the `field` value. When
Expand Down