@commercelayer/cli
Version:
23 lines (22 loc) • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const cli_core_1 = require("@commercelayer/cli-core");
const update_notifier_cjs_1 = tslib_1.__importDefault(require("update-notifier-cjs"));
const pkg = require('../../../package.json');
const UPDATE_COMMAND = 'cli:update';
const hook = async function (opts) {
// Do not check for updates if in invisible mode or running the update command
if (opts.argv.includes('--blind') || opts.argv.includes('--silent'))
return;
if ([UPDATE_COMMAND].includes(opts.id || ''))
return;
const notifier = (0, update_notifier_cjs_1.default)({ pkg, updateCheckInterval: (process.env.CL_CLI_UPDATE_NOTIFY ? 0 : 1000 * 60 * 60) });
const updateCommand = /* '{updateCommand}' */ 'commercelayer ' + UPDATE_COMMAND;
notifier.notify({
isGlobal: true,
message: `-= ${cli_core_1.clColor.bg.white.black.bold(` ${pkg.description} `)} =-\n\nNew version available: ${cli_core_1.clColor.dim('{currentVersion}')} -> ${cli_core_1.clColor.green('{latestVersion}')}\nRun ${cli_core_1.clColor.cyanBright(updateCommand)} to update`,
});
// console.log(notifier.update)
};
exports.default = hook;