balena-cli
Version:
The official balena Command Line Interface
45 lines • 1.61 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.notify = notify;
exports.getNotifierMessage = getNotifierMessage;
const isRoot = require("is-root");
const UpdateNotifier = require("update-notifier");
const packageJSON = require("../../package.json");
const balenaUpdateInterval = 1000 * 60 * 60 * 24 * 1;
let notifier;
function notify() {
if (!notifier) {
if (isRoot()) {
return;
}
else {
notifier = UpdateNotifier({
pkg: packageJSON,
updateCheckInterval: balenaUpdateInterval,
});
}
}
const up = notifier.update;
const message = up && getNotifierMessage(up);
if (message) {
notifier.notify({ defer: false, message });
}
}
function getNotifierMessage(updateInfo) {
const semver = require('semver');
const message = [];
const [current, latest] = [updateInfo.current, updateInfo.latest];
if (semver.lt(current, latest)) {
message.push(`Update available ${current} → ${latest}`, 'https://github.com/balena-io/balena-cli/blob/master/INSTALL.md');
const currentMajor = semver.major(current);
const latestMajor = semver.major(latest);
if (currentMajor !== latestMajor) {
message.push('', `Check the v${latestMajor} release notes at:`, getReleaseNotesUrl(latestMajor));
}
}
return message.join('\n');
}
function getReleaseNotesUrl(majorVersion) {
return `https://github.com/balena-io/balena-cli/releases/tag/v${majorVersion}.0.0`;
}
//# sourceMappingURL=update.js.map
;