autoupdater
Version:
Make your module auto-update itself
48 lines (33 loc) • 553 B
JavaScript
/**
* Dependencies
*/
var updateNotifier = require('update-notifier');
var spawn = require('child_process').spawn;
/**
* Expose autoupdater
*/
module.exports = autoupdater;
/**
* Autoupdater
*/
function autoupdater (pkg) {
var notifier = updateNotifier({
pkg: pkg
});
if (notifier.update) {
var options = {
env: process.env
};
var args = [
'install',
'--global',
pkg.name
];
spawn('npm', args, options, noop).unref();
}
}
/**
* Utilities
*/
function noop () {}
;