UNPKG

1.21 kBMarkdownView Raw
1latest
2======
3
4Quickly determine the latest available version of a package in [npm](http://npmjs.org)
5
6Useful for command line tools that want to check for available upgrades
7
8Example
9-------
10
11Get the latest version number of `autocast`
12
13``` js
14var latest = require('latest');
15
16latest('autocast', function(err, v) {
17 console.log(v);
18});
19```
20yields
21```
220.0.3
23```
24
25Errors passed directly from npm
26
27``` js
28var latest = require('latest');
29
30latest('i-hope-this-package-never-exists', function(err, v) {
31 if (err) console.error(err.message);
32});
33```
34yields
35```
36404 Not Found: i-hope-this-package-never-exists
37```
38
39### Convenience Function
40
41Check for upgrades in an app
42
43``` js
44var latest = require('latest');
45var p = require('./package.json');
46
47latest.checkupdate(p, function(ret, message) {
48 console.log(message);
49 process.exit(ret);
50});
51```
52
53#### checkupdate(package-json-obj, cb(ret, message))
54
55A convenience method that will check for newer versions of a module in npm given a
56`package.json` object as the first argument.
57
58The callback fires with a return code suitable for exiting with, and a message to print
59
60Install
61------
62
63 npm install latest
64
65Tests
66-----
67
68 npm test
69
70License
71-------
72
73MIT Licensed