From b6ff85a8ca25dd77d24ca7019b29c214b4fabfe5 Mon Sep 17 00:00:00 2001 From: Xiaoxin Lu Date: Fri, 10 Feb 2017 09:40:34 -0500 Subject: [PATCH] feat: add update notifier to cli --- index.js | 5 +++++ package.json | 3 ++- test/test.ddns.js | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ab46c1c..d0951cd 100755 --- a/index.js +++ b/index.js @@ -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 { diff --git a/package.json b/package.json index 7638217..75b04d4 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/test.ddns.js b/test/test.ddns.js index a5b5da2..f005b97 100644 --- a/test/test.ddns.js +++ b/test/test.ddns.js @@ -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) + }) })