Comparing version 1.1.0 to 1.2.0
@@ -13,3 +13,4 @@ 'use strict'; | ||
output: 'pretty', | ||
slurp: false | ||
slurp: false, | ||
sort: false | ||
}; | ||
@@ -54,2 +55,9 @@ | ||
} | ||
}, | ||
sort: { | ||
buildParams: function buildParams(filter, json, params, value) { | ||
if (value === true) { | ||
params.unshift('--sort-keys'); | ||
} | ||
} | ||
} | ||
@@ -56,0 +64,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
{"name":"node-jq","version":"1.1.0","description":"Run jq in node","main":"lib/jq.js","repository":{"type":"git","url":"https://github.com/sanack/node-jq"},"scripts":{"pretest":"npm run install-binary","install-binary":"node scripts/install-binary.js","test":"mocha --compilers js:babel-register","test:watch":"npm test -- --watch","lint":"standard --verbose | snazzy","build":"babel src -d lib","prepublish":"npm test && npm run lint && npm run build","postinstall":"npm run install-binary","coverage":"babel-node ./node_modules/.bin/isparta cover _mocha","precodeclimate":"npm run coverage","codeclimate":"codeclimate-test-reporter < coverage/lcov.info","semantic-release":"semantic-release pre && npm publish && semantic-release post","commitmsg":"validate-commit-msg","precommit":"npm run lint","prepush":"npm test"},"engines":{"npm":">=6.0.0"},"keywords":["jq","json"],"author":"sanack","contributors":[{"name":"davesnx","email":"dsnxmoreno@gmail.com"},{"name":"mackermans","email":"maarten.ackermans@gmail.com"}],"license":"MIT","files":["src","lib","scripts","docs"],"dependencies":{"bin-build":"^2.2.0","download":"^6.0.0","is-valid-path":"^0.1.1","strip-eof":"^1.0.0","tempfile":"^2.0.0"},"devDependencies":{"babel-cli":"^6.10.1","babel-preset-es2015":"^6.9.0","babel-preset-stage-1":"^6.5.0","babel-register":"^6.9.0","chai":"^4.0.1","codeclimate-test-reporter":"^0.4.1","coveralls":"^3.0.0","husky":"^0.14.0","isparta":"^4.0.0","mocha":"^4.0.0","semantic-release":"^8.2.0","snazzy":"^6.0.0","standard":"^10.0.0","tap-diff":"^0.1.1","validate-commit-msg":"^2.11.2"},"babel":{"presets":["es2015","stage-1"]},"standard":{"global":["describe","it"]}} | ||
{"name":"node-jq","version":"1.2.0","description":"Run jq in node","main":"lib/jq.js","repository":{"type":"git","url":"https://github.com/sanack/node-jq"},"scripts":{"pretest":"npm run install-binary","install-binary":"node scripts/install-binary.js","test":"mocha --compilers js:babel-register","test:watch":"npm test -- --watch","lint":"standard --verbose | snazzy","build":"babel src -d lib","prepublish":"npm test && npm run lint && npm run build","postinstall":"npm run install-binary","coverage":"babel-node ./node_modules/.bin/isparta cover _mocha","precodeclimate":"npm run coverage","codeclimate":"codeclimate-test-reporter < coverage/lcov.info","semantic-release":"semantic-release pre && npm publish && semantic-release post","commitmsg":"validate-commit-msg","precommit":"npm run lint","prepush":"npm test"},"engines":{"npm":">=6.0.0"},"keywords":["jq","json"],"author":"sanack","contributors":[{"name":"davesnx","email":"dsnxmoreno@gmail.com"},{"name":"mackermans","email":"maarten.ackermans@gmail.com"}],"license":"MIT","files":["src","lib","scripts","docs"],"dependencies":{"bin-build":"^2.2.0","download":"^6.0.0","is-valid-path":"^0.1.1","strip-eof":"^1.0.0","tempfile":"^2.0.0"},"devDependencies":{"babel-cli":"^6.10.1","babel-preset-es2015":"^6.9.0","babel-preset-stage-1":"^6.5.0","babel-register":"^6.9.0","chai":"^4.0.1","codeclimate-test-reporter":"^0.4.1","coveralls":"^3.0.0","husky":"^0.14.0","isparta":"^4.0.0","mocha":"^4.0.0","semantic-release":"^8.2.0","snazzy":"^6.0.0","standard":"^10.0.0","tap-diff":"^0.1.1","validate-commit-msg":"^2.11.2"},"babel":{"presets":["es2015","stage-1"]},"standard":{"global":["describe","it"]}} |
@@ -197,2 +197,18 @@ <p align="center"> | ||
### sort | ||
| Description | Values | Default | | ||
|:-------------------------------------:|:---------------:|:-------:| | ||
| Sort object keys in alphabetical order| `true`, `false` | `false` | | ||
#### `sort: true` | ||
Sorts object keys alphabetically. | ||
```js | ||
jq.run('.', ['/path/to/file.json'], { output: 'json', sort: true }).then(console.log) | ||
// { | ||
// "a": 2, | ||
// "b": 1 | ||
// }, | ||
``` | ||
## Projects using **node-jq** | ||
@@ -199,0 +215,0 @@ |
@@ -6,3 +6,4 @@ import { validateJSONPath } from './utils' | ||
output: 'pretty', | ||
slurp: false | ||
slurp: false, | ||
sort: false | ||
} | ||
@@ -47,2 +48,9 @@ | ||
} | ||
}, | ||
sort: { | ||
buildParams: (filter, json, params, value) => { | ||
if (value === true) { | ||
params.unshift('--sort-keys') | ||
} | ||
} | ||
} | ||
@@ -49,0 +57,0 @@ } |
69593
378
249