Skip to content

Commit 4be51a9

Browse files
Joe Bottiglierozkat
Joe Bottigliero
authored andcommittedNov 26, 2018
cli,outdated: Adds 'Homepage' to outdated --long output. (#81)
* feat(cli, outdated): Adds 'Homepage' to outdated --long output. - `package.json`'s `homepage` property is displayed when using the `--long` option for `npm outdated` * test: npm outdated --long - Adds `homepage` to `--parseable` output. - Updates `npm outdated --long` test to include `homepage` in expected output. - Adds `homepage` to `npm-outdated` documentation. * fix: javascript standard style updates PR-URL: #81 Credit: @jbottigliero Reviewed-By: @zkat
1 parent 71d8fb4 commit 4be51a9

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed
 

‎doc/cli/npm-outdated.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ In the output:
2727
* `package type` (when using `--long` / `-l`) tells you whether this package is
2828
a `dependency` or a `devDependency`. Packages not included in `package.json`
2929
are always marked `dependencies`.
30+
* `homepage` (when using `--long` / `-l`) is the `homepage` value contained in the package's `package.json`
3031
* Red means there's a newer version matching your semver requirements, so you should update now.
3132
* Yellow indicates that there's a newer version above your semver requirements (usually new major, or new 0.x minor) so proceed with caution.
3233

‎lib/outdated.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function outdated (args, silent, cb) {
9494
'Latest',
9595
'Location'
9696
]
97-
if (long) outHead.push('Package Type')
97+
if (long) outHead.push('Package Type', 'Homepage')
9898
var outTable = [outHead].concat(outList)
9999

100100
if (npm.color) {
@@ -123,14 +123,18 @@ function makePretty (p) {
123123
var latest = p[4]
124124
var type = p[6]
125125
var deppath = p[7]
126+
var homepage = p[0].package.homepage
126127

127128
var columns = [ depname,
128129
has || 'MISSING',
129130
want,
130131
latest,
131132
deppath
132133
]
133-
if (long) columns[5] = type
134+
if (long) {
135+
columns[5] = type
136+
columns[6] = homepage
137+
}
134138

135139
if (npm.color) {
136140
columns[0] = color[has === want || want === 'linked' ? 'yellow' : 'red'](columns[0]) // dep
@@ -157,7 +161,7 @@ function makeParseable (list) {
157161
(has ? (depname + '@' + has) : 'MISSING'),
158162
depname + '@' + latest
159163
]
160-
if (long) out.push(type)
164+
if (long) out.push(type, dep.package.homepage)
161165

162166
return out.join(':')
163167
}).join(os.EOL)
@@ -181,7 +185,10 @@ function makeJSON (list) {
181185
latest: latest,
182186
location: dir
183187
}
184-
if (long) out[depname].type = type
188+
if (long) {
189+
out[depname].type = type
190+
out[depname].homepage = dep.package.homepage
191+
}
185192
})
186193
return JSON.stringify(out, null, 2)
187194
}

‎test/tap/outdated-long.js

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ test('it should not throw', function (t) {
7474
npm.install('.', function (err) {
7575
t.ifError(err, 'install success')
7676
npm.config.set('long', true)
77+
// since it's possible for the homepage of a package to change, after the
78+
// install we read the value from the package.json directly to specify our
79+
// expected output.
80+
expOut[1] = expOut[1] + ':' + JSON.parse(fs.readFileSync(path.resolve(pkg, 'node_modules', 'underscore', 'package.json'))).homepage
7781
npm.outdated(function (er, d) {
7882
t.ifError(err, 'npm outdated ran without error')
7983
t.is(process.exitCode, 1, 'exit code set to 1')

0 commit comments

Comments
 (0)
Please sign in to comment.