Skip to content

Commit 62da50d

Browse files
authored
Merge pull request #94 from jo/pretty-output
feat(cli): pretty JSON output
2 parents 6c13106 + debed59 commit 62da50d

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

.travis.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ notifications:
77
email: false
88
node_js:
99
- stable
10-
- 5
11-
- 4
12-
- '0.12'
13-
before_install:
14-
- npm i -g npm@^2.0.0
15-
before_script:
16-
- npm prune
1710
after_success:
1811
- npm run semantic-release
1912
branches:

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ couchdb-compile [SOURCE] [OPTIONS]
4444
```
4545

4646
When `SOURCE` is omitted, the current directory will be used.
47-
`OPTIONS` can be `--index`, see above.
47+
`OPTIONS` can be `--index` and `--pretty`, see above.
48+
49+
Use `--pretty` to get a pretty printed json output.
4850

4951
### Example
5052

5153
```sh
5254
couchdb-compile project/couchdb
55+
couchdb-compile project/couchdb --pretty
5356
```
5457

5558
## The CouchDB Directory Tree

cli.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@ var stringify = require('json-stable-stringify')
44
var compile = require('./')
55

66
var options = minimist(process.argv.slice(2), {
7-
boolean: ['index']
7+
boolean: ['index', 'pretty']
88
})
99

10+
var stringifyOptions = {}
11+
12+
if (options.pretty) {
13+
stringifyOptions.space = 2
14+
}
15+
1016
options.multipart = false
1117

1218
var source = options._[0] || process.cwd()
1319

1420
compile(source, options, function (error, response) {
1521
if (error) return console.error(error)
1622

17-
console.log(stringify(response))
23+
console.log(stringify(response, stringifyOptions))
1824
})

0 commit comments

Comments
 (0)