1import chalk from 'chalk'; 2import checkForUpdate from 'update-check'; 3 4const packageJson = require('../package.json'); 5 6const debug = require('debug')('expo:init:update-check') as typeof console.log; 7 8export default async function shouldUpdate(): Promise<void> { 9 try { 10 const res = await checkForUpdate(packageJson); 11 if (res?.latest) { 12 console.log(); 13 console.log(chalk.yellow.bold(`A new version of \`${packageJson.name}\` is available`)); 14 console.log(chalk`You can update by running: {cyan npm install -g ${packageJson.name}}`); 15 console.log(); 16 } 17 } catch (error: any) { 18 debug('Error checking for update:\n%O', error); 19 } 20} 21