pkg-jq
TypeScript icon, indicating that this package has built-in type declarations

0.2.11 • Public • Published

pkg-jq

NPM Version npm (tag) NPM TypeScript

pkg-jq

Source: Processing JSON Data With jq

Find the nearest package.json then deal with jq syntax on it. (in-line edit supported!)

FEATURES

  1. Search package.json in current and all parent directories by default, powered by pkg-up.
  2. Use jq syntax to deal with the json file, powered by node-jq.
  3. In-place edit support by specify a -i or --in-place argument.

USAGE

$ npm-jq --help
usage: pkg-jq [-h] [-v] [-i] [-r] filter [path]

Node.js Package jq Utility

Positional arguments:
  filter          jq filter.
  path            npm project subdir, or json file. default: $PWD.

Optional arguments:
  -h, --help      Show this help message and exit.
  -v, --version   Show programs version number and exit.
  -i, --in-place  edit files in place.
  -r, --raw       output raw strings, not JSON texts.


Exmaple: pkg-jq -i '.publishConfig.tag="next"'

1. Query

$ grep version package.json
  "version": "0.0.6",

$ pkg-jq .version
"0.0.6"

# Raw mode: -r
$ pkg-jq -r .version
0.0.6

2. Edit In Place

$ grep -E 'publish|tag' package.json
  "publishConfig": {
    "tag": "next"

$ pkg-jq -i '.publishConfig.tag="latest"'

$ grep -E 'publish|tag' package.json
  "publishConfig": {
    "tag": "latest"

DEVELOPMENT

Ubuntu

sudo apt-get install libtool

HISTORY

master

v0.2 (10 Jun 2019)

  1. Support in-line edit by -i parameter
  2. Support raw mode by -r parameter
  3. Good unit tests coverage
  4. Travis CI DevOps

v0.0.1 (09 Jun 2019)

  1. Project inited.

AUTHOR

Huan LI (李卓桓) zixia@zixia.net

Profile of Huan LI (李卓桓) on StackOverflow

COPYRIGHT & LICENSE

  • Code & Docs © 2019 - now Huan LI zixia@zixia.net
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons

Readme

Keywords

Package Sidebar

Install

npm i pkg-jq

Weekly Downloads

4,737

Version

0.2.11

License

Apache-2.0

Unpacked Size

90.1 kB

Total Files

71

Last publish

Collaborators

  • zixia