npm

Join us for the upcoming webinar, "Enterprise JavaScript done right: the tools you love, the security you need."Sign up here »

get-latest

0.1.0 • Public • Published

get-latest NPM version NPM downloads Build Status

Get the latest package.json for a module.

You might also be interested in get-pkg.

Install

Install with npm:

$ npm install --save get-latest

What does this module do?

This module will return the latest (or newest) package.json file for a specified module. The getLatest function requires the current package.json file to be able to compare versions and return the current package.json if the latest hasn't been downloaded yet.

The first use of get-latest will always return the current package.json because the latest has not been downloaded. Once the latest is downloaded and cached, then the latest version will be returned.

This is intended to be used by CLIs and applications that want to quickly check for the latest version without blocking execution, but still download the latest to be used during the next execution of the CLI or application.

Usage

var pkg = require('./package.json');
var getLatest = require('get-latest');
var latest = getLatest(pkg);
console.log('current', pkg.version);
console.log('latest', latest.version);
//=> 'current 0.1.0'
//=> 'latest' 0.2.0'

API

getLatest

Get the latest package.json for the specified package.json and given options.

This library will use the given package.json to determine if it's the latest one or if there is a newer version. If the given package.json is the latest, then it is returned.

Params

  • pkg {Object}: Current package.json to use for checking for the latest.
  • options {Object}: Additional options to control how the checking is handled.
  • options.timespan {String}: String used to determine if the background process should be started to npm for the latest version. Defaults to '1 hour ago'.
  • options.cache {Boolean}: Set to false to ensure that the background process is always started.
  • returns {Object}: Latest package.json is returned.

Example

var latest = getLatest(require('./package.json'));

About

Related projects

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Please read the contributing guide for avice on opening issues, pull requests, and coding standards.

Building docs

(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

To generate the readme and API documentation with verb:

$ npm install -g verb verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Brian Woodward

License

Copyright © 2016, Brian Woodward. Released under the MIT license.


This file was generated by verb, v0.9.0, on August 17, 2016.

install

npm i get-latest

Downloadsweekly downloads

38

version

0.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability