Giter Site home page Giter Site logo

dbillingham / update-check Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vercel/update-check

0.0 2.0 0.0 28 KB

Minimalistic update notifications for command line interfaces

Home Page: https://npmjs.com/update-check

License: MIT License

JavaScript 100.00%

update-check's Introduction

update-check

npm version install size

This is a very minimal approach to update checking for globally installed packages.

Because it's so simple, the error surface is very tiny and your user's are guaranteed to receive the update message if there's a new version.

You can read more about the reasoning behind this project here.

Usage

Firstly, install the package with yarn...

yarn add update-check

...or npm:

npm install update-check

Next, initialize it.

If there's a new update available, the package will return the content of latest version's package.json file:

const pkg = require('./package');
const checkForUpdate = require('update-check');

let update = null;

try {
	update = await checkForUpdate(pkg);
} catch (err) {
	console.error(`Failed to check for updates: ${err}`);
}

if (update) {
	console.log(`The latest version is ${update.latest}. Please update!`);
}

That's it! You're done.

Configuration

If you want, you can also pass options to customize the package's behavior:

const pkg = require('./package');
const checkForUpdate = require('update-check');

let update = null;

try {
	update = await checkForUpdate(pkg, {
		interval: 3600000,  // For how long to cache latest version (default: 1 day)
		distTag: 'canary'   // A npm distribution tag for comparision (default: 'latest')
	});
} catch (err) {
	console.error(`Failed to check for updates: ${err}`);
}

if (update) {
	console.log(`The latest version is ${update.latest}. Please update!`);
}

Contributing

  1. Fork this repository to your own GitHub account and then clone it to your local device
  2. Link the package to the global module directory: npm link
  3. Within the module you want to test your local development instance of the package, just link it: npm link update-check. Instead of the default one from npm, node will now use your clone.

Author

Leo Lamprecht (@notquiteleo) - ZEIT

update-check's People

Contributors

ansballard avatar leo avatar luksm avatar styfle avatar timneutkens avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.