UNPKG

@adpt/cli

Version:
56 lines 2.2 kB
"use strict"; /* * Copyright 2020 Unbounded Systems, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const utils_1 = require("@adpt/utils"); const debug_1 = tslib_1.__importDefault(require("debug")); const path_1 = tslib_1.__importDefault(require("path")); const config_1 = require("../config"); const upgrade_checker_1 = require("./upgrade_checker"); const debug = debug_1.default("adapt:upgrade"); const hook = async () => { const conf = await config_1.config(); const enabled = conf.user.upgradeCheck; debug(`Upgrade check is ${enabled}`); if (!enabled) return; try { const checker = new upgrade_checker_1.UpgradeChecker({ channel: conf.user.upgradeChannel, configDir: conf.package.configDir, logDir: path_1.default.join(conf.package.cacheDir, "logs"), upgradeCheckInterval: conf.user.upgradeCheckInterval, upgradeCheckUrl: conf.user.upgradeCheckUrl, upgradeRemindInterval: conf.user.upgradeRemindInterval, upgradeIgnore: conf.user.upgradeIgnore, }, conf.state); await checker.check(); utils_1.onExit(async (signal, code) => { if (signal === "exit" && code === 0) { const msg = await checker.notifyString({ fancy: true }); // tslint:disable-next-line: no-console if (msg) console.log(msg); } }); } catch (err) { debug(`Error starting upgrade check:`, err); } }; exports.default = hook; //# sourceMappingURL=init.js.map