react-native-flip
Version:
38 lines • 1.37 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
const child_process_1 = require("child_process");
const update_check_1 = __importDefault(require("update-check"));
function shouldUseYarn() {
try {
child_process_1.execSync('yarnpkg --version', { stdio: 'ignore' });
return true;
}
catch {
return false;
}
}
async function shouldUpdate() {
const packageJson = () => require('../package.json');
const update = update_check_1.default(packageJson()).catch(() => null);
try {
const res = await update;
if (res && res.latest) {
const isYarn = shouldUseYarn();
const _packageJson = packageJson();
console.log();
console.log(chalk_1.default.yellow.bold(`A new version of \`${_packageJson.name}\` is available`));
console.log('You can update by running: ' +
chalk_1.default.cyan(isYarn ? `yarn global add ${_packageJson.name}` : `npm i -g ${_packageJson.name}`));
console.log();
}
}
catch {
// ignore error
}
}
exports.default = shouldUpdate;
//# sourceMappingURL=update.js.map