-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check for updates to common execution targets
- Loading branch information
Showing
4 changed files
with
47 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,3 @@ | ||
const info = require('../lib/log').info; | ||
const request = require('request-promise-native'); | ||
const warn = require('../lib/log').warn; | ||
const checkForUpdates = require('../lib/check-for-updates'); | ||
|
||
module.exports = () => request | ||
.get('https://registry.npmjs.org/medic-configurer-beta') | ||
.then(res => { | ||
const json = JSON.parse(res); | ||
const latest = json['dist-tags'].latest; | ||
const current = require('../../package').version; | ||
|
||
info(`Current version: ${current}`); | ||
if(latest === current) { | ||
info('You are already on the latest version :¬)'); | ||
} else { | ||
warn(`New version available! | ||
${current} -> ${latest} | ||
To install: | ||
npm install -g medic-configurer-beta | ||
`); | ||
} | ||
}); | ||
module.exports = () => checkForUpdates(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const info = require('../lib/log').info; | ||
const request = require('request-promise-native'); | ||
const warn = require('../lib/log').warn; | ||
|
||
module.exports = (options) => { | ||
if(!options) options = {}; | ||
|
||
return request | ||
.get('https://registry.npmjs.org/medic-configurer-beta') | ||
.then(res => { | ||
const json = JSON.parse(res); | ||
const latest = json['dist-tags'].latest; | ||
const current = require('../../package').version; | ||
|
||
info(`Current version: ${current}`); | ||
if(latest === current) { | ||
info('You are already on the latest version :¬)'); | ||
} else { | ||
warn(`New version available! | ||
${current} -> ${latest} | ||
To install: | ||
npm install -g medic-configurer-beta | ||
`); | ||
} | ||
}) | ||
.catch(err => { | ||
if(options.nonFatal && err.cause && err.cause.code === 'ENOTFOUND') { | ||
warn('Could not check NPM for updates. You may be offline.'); | ||
} else throw err; | ||
}) | ||
; | ||
} |