Skip to content

Commit

Permalink
add update-notifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Flet committed Sep 25, 2017
1 parent 82eaa9f commit 9848b42
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ cache:
- node_modules
env:
- BBY_API_KEY=XXX
- NO_UPDATE_NOTIFIER=1
10 changes: 7 additions & 3 deletions bin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env node
const BBY_API_KEY_MSG = 'BBY_API_KEY environment variable'
const RESOURCES = ['products', 'categories', 'stores']
const pkg = require('./package')
const updateNotifier = require('update-notifier')

const run = require('.')

Expand Down Expand Up @@ -67,7 +69,7 @@ function cli (args, stream, cb) {
argv.resource = argv.resource || argv._[0]

if (argv.version) {
stream.write(require('./package').version + '\n')
stream.write(pkg.version + '\n')
return cb()
}

Expand Down Expand Up @@ -104,11 +106,13 @@ Usage: bestbuy [resource] [options]

if (require.main === module) {
cli(process.argv.slice(2), process.stdout, function done (err) {
var code = 0
if (err) {
console.error(err.message)
process.exit(-1)
code = -1
}
process.exit(0)
updateNotifier({pkg: pkg}).notify()
process.exit(code)
})
} else {
module.exports = cli
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"pretty-ms": "^3.0.0",
"pump": "^1.0.2",
"stdout-stream": "^1.4.0",
"through2": "^2.0.3"
"through2": "^2.0.3",
"update-notifier": "^2.2.0"
},
"devDependencies": {
"concat-stream": "^1.6.0",
Expand Down

0 comments on commit 9848b42

Please sign in to comment.