get-latest
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 = ;var getLatest = ;var latest = ;console;console;//=> '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 tofalse
to ensure that the background process is always started.returns
{Object}: Latest package.json is returned.
Example
var latest = ;
About
Related projects
- background-process: Run a process in the background, disconnected from the main process. | homepage
- data-store: Easily get, set and persist config data. | homepage
- date-store: Easily persist or get stored dates/times. Useful for conditionally making updates in an application based… more | homepage
- get-pkg: Get the package.json for a project from npm. | homepage
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.