Skip to content

Commit

Permalink
always return json when requested (empty array rather than error)
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed Sep 23, 2017
1 parent 6f3a596 commit 242d149
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions cli.js
Expand Up @@ -4,17 +4,18 @@ const get = require('.')

const argv = require('minimist')(process.argv.slice(2))

get({
term: argv._.join(' '),
reading: argv.r
}).then(results => {
if (!results.length) {
process.exit(61)
}
const term = argv._.join(' ')
const reading = argv.r
const jsonMode = argv.j

if (argv.j) {
get({term, reading}).then(results => {
if (jsonMode) {
return console.log(JSON.stringify(results))
}

console.log(results.join('\n'))
if (results.length) {
return console.log(results.join('\n'))
}

process.exit(61)
})

0 comments on commit 242d149

Please sign in to comment.