Skip to content

Commit

Permalink
feat: add update notifier to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperlink committed Feb 10, 2017
1 parent ad3d5d2 commit b6ff85a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

'use strict'

const updateNotifier = require('update-notifier')
const pkg = require('./package')

updateNotifier({pkg}).notify()

if (!process.env.DIGITAL_OCEAN_TOKEN || !process.env.SERVER_NAME) {
console.error('Missing required environment variables: DIGITAL_OCEAN_TOKEN or SERVER_NAME')
} else {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"bluebird": "^3.4.6",
"digitalocean": "^0.9.1",
"lodash": "^4.15.0",
"public-ip": "^2.1.0"
"public-ip": "^2.1.0",
"update-notifier": "^1.0.3"
},
"devDependencies": {
"mocha": "^3.2.0",
Expand Down
11 changes: 11 additions & 0 deletions test/test.ddns.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,15 @@ describe('Dynamic DNS Client', function () {
require('../')
sinon.assert.calledWithExactly(console.error, 'Missing required environment variables: DIGITAL_OCEAN_TOKEN or SERVER_NAME')
})

it('should call updateNotifier notify', function () {
const notify = sandbox.stub()
const updateNotifier = sandbox.stub().returns({ notify })
proxyquire('../', {
'update-notifier': updateNotifier
})
sinon.assert.calledWith(updateNotifier, sinon.match.object)
sinon.assert.calledOnce(notify)
notify.calledAfter(updateNotifier)
})
})

0 comments on commit b6ff85a

Please # to comment.