lib/util/setupCLI.js
function ShowVersion(packageJson) {
  const pkgName = packageJson.name;
  let latestVer = spawnSync(`npm show ${pkgName} version`, {
    shell: true,
    stdio: ['inherit', 'pipe', 'inherit'],
  }).stdout;

  let latestVerStr = '';
  if (latestVer) {
    latestVer = latestVer.toString('utf-8').replace(/\s/gm, '');
    if (latestVer !== packageJson.version) {
      const osType = os.type();
      const sudo = (osType === 'Linux' || osType === 'Darwin') ? 'sudo ' : '';
      latestVerStr = `Latest version on npm: ${col.warning(latestVer).bold}
Run "${col.warning(`${sudo}npm install -g ${pkgName}@latest`)}" to upgrade.`;
    } else {
      latestVerStr = `${col.success('up-to-date!')}`;
    }
  }
  return `${packageJson.version}\n${latestVerStr}`;
}
function ShowVersion(packageJson) {
  const pkgName = packageJson.name;
  let latestVer = spawnSync(`npm show ${pkgName} version`, {
    shell: true,
    stdio: ['inherit', 'pipe', 'inherit'],
  }).stdout;

  let latestVerStr = '';
  if (latestVer) {
    latestVer = latestVer.toString('utf-8').replace(/\s/gm, '');
    if (latestVer !== packageJson.version) {
      const osType = os.type();
      const sudo = (osType === 'Linux' || osType === 'Darwin') ? 'sudo ' : '';
      latestVerStr = `Latest version on npm: ${col.warning(latestVer).bold}
Run "${col.warning(`${sudo}npm install -g ${pkgName}@latest`)}" to upgrade.`;
    } else {
      latestVerStr = `${col.success('up-to-date!')}`;
    }
  }
  return `${packageJson.version}\n${latestVerStr}`;
}
function ShowVersion ( packageJson ) { const pkgName = packageJson . name ; let latestVer = spawnSync ( ` ${ pkgName } ` , { shell : true , stdio : [ 'inherit' , 'pipe' , 'inherit' ] , } ) . stdout ; let latestVerStr = '' ; if ( latestVer ) { latestVer = latestVer . toString ( 'utf-8' ) . replace ( / \s / gm , '' ) ; if ( latestVer !== packageJson . version ) { const osType = os . type ( ) ; const sudo = ( osType === 'Linux' || osType === 'Darwin' ) ? 'sudo ' : '' ; latestVerStr = ` ${ col . warning ( latestVer ) . bold } ${ col . warning ( ` ${ sudo } ${ pkgName } ` ) } ` ; } else { latestVerStr = ` ${ col . success ( 'up-to-date!' ) } ` ; } } return ` ${ packageJson . version } \n ${ latestVerStr } ` ; }
Check for latest package version on npm, return warning on outdated version.
Check for latest package version on npm return warning on outdated version .