How to use update-check - 4 common examples

To help you get started, we’ve selected a few update-check examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zeit / now / src / index.js View on Github external
if (localConfig instanceof NowError && !(localConfig instanceof ERRORS.CantFindConfig)) {
    output.error(`Failed to load local config file: ${localConfig.message}`);
    return 1;
  }

  // the second argument to the command can be a path
  // (as in: `now path/`) or a subcommand / provider
  // (as in: `now ls`)
  const targetOrSubcommand = argv._[2];

  let update = null;

  try {
    if (targetOrSubcommand !== 'update') {
      update = await checkForUpdate(pkg, {
        interval: ms('1d'),
        distTag: pkg.version.includes('canary') ? 'canary' : 'latest'
      });
    }
  } catch (err) {
    console.error(
      error(`Checking for updates failed${isDebugging ? ':' : ''}`)
    );

    if (isDebugging) {
      console.error(err);
    }
  }

  if (update && isTTY) {
    console.log(
github zeit / now / packages / now-cli / src / index.js View on Github external
!(localConfig instanceof ERRORS.CantFindConfig)
  ) {
    output.error(`Failed to load local config file: ${localConfig.message}`);
    return 1;
  }

  // the second argument to the command can be a path
  // (as in: `now path/`) or a subcommand / provider
  // (as in: `now ls`)
  const targetOrSubcommand = argv._[2];

  let update = null;

  try {
    if (targetOrSubcommand !== 'update') {
      update = await checkForUpdate(pkg, {
        interval: ms('1d'),
        distTag: pkg.version.includes('canary') ? 'canary' : 'latest',
      });
    }
  } catch (err) {
    console.error(
      error(`Checking for updates failed${isDebugging ? ':' : ''}`)
    );

    if (isDebugging) {
      console.error(err);
    }
  }

  if (update && isTTY) {
    console.log(
github flood-io / element / packages / cli / src / utils / updateCheck.ts View on Github external
console.error(error(`Failed to read package.json while checking for update`))
		return
	}

	try {
		// 1.0.1 -> latest
		// 1.0.1-beta.1 -> beta
		const validDistTags = ['latest', 'beta']
		let distTag = 'latest'

		const versionParts = prerelease(pkg.version) || []
		if (versionParts) {
			if (validDistTags.includes(versionParts[0])) distTag = versionParts[0]
		}

		const update = await checkForUpdate(pkg, {
			interval: ms('1d'),
			distTag,
		})

		if (update) {
			printUpdateMessage(pkg.version, distTag, update)
		}
	} catch (err) {
		console.error(error(`Checking for updates failed`))

		console.error(err)
	}
}
github expo / expo-cli / packages / expo-optimize / src / update.ts View on Github external
export default async function shouldUpdate() {
  const packageJson = () => require('../package.json');

  const update = checkForUpdate(packageJson()).catch(() => null);

  try {
    const res = await update;
    if (res && res.latest) {
      const isYarn = shouldUseYarn();

      const _packageJson = packageJson();
      console.log();
      console.log(chalk.yellow.bold(`A new version of \`${_packageJson.name}\` is available`));
      console.log(
        'You can update by running: ' +
          chalk.cyan(
            isYarn ? `yarn global add ${_packageJson.name}` : `npm i -g ${_packageJson.name}`
          )
      );
      console.log();

update-check

Minimalistic update notifications for command line interfaces

MIT
Latest version published 4 years ago

Package Health Score

71 / 100
Full package analysis

Popular update-check functions