Skip to content

Commit ef8f567

Browse files
committed
view: always fetch fullMetadata, and preferOnline
PR-URL: #1757 Credit: @isaacs Close: #1757 Reviewed-by: @ruyadorno
1 parent 0d586c8 commit ef8f567

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

lib/view.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const completion = async (opts, cb) => {
2929
return cb()
3030
}
3131
// have the package, get the fields
32-
const config = npm.flatOptions
32+
const config = { ...npm.flatOptions, fullMetadata: true, preferOnline: true }
3333
const { defaultTag } = config
3434
const spec = npa(opts.conf.argv.remain[2])
3535
const pckmnt = await packument(spec, config)
@@ -63,7 +63,7 @@ const completion = async (opts, cb) => {
6363
const view = async args => {
6464
if (!args.length) args = ['.']
6565

66-
const opts = npm.flatOptions
66+
const opts = { ...npm.flatOptions, preferOnline: true, fullMetadata: true }
6767
const pkg = args.shift()
6868
let nv
6969
if (/^[.]@/.test(pkg)) {
@@ -97,11 +97,7 @@ const fetchAndRead = async (nv, args, opts) => {
9797
// get the data about this package
9898
let version = nv.rawSpec || npm.flatOptions.defaultTag
9999

100-
const pckmnt = await packument(nv, {
101-
...opts,
102-
fullMetadata: true,
103-
'prefer-online': true
104-
})
100+
const pckmnt = await packument(nv, opts)
105101

106102
if (pckmnt['dist-tags'] && pckmnt['dist-tags'][version]) {
107103
version = pckmnt['dist-tags'][version]

test/lib/view.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ const cleanLogs = (done) => {
1212
done()
1313
}
1414

15-
const packument = (nv) => {
15+
const packument = (nv, opts) => {
16+
if (!opts.fullMetadata) {
17+
throw new Error('must fetch fullMetadata')
18+
}
19+
20+
if (!opts.preferOnline) {
21+
throw new Error('must fetch with preferOnline')
22+
}
23+
1624
const mocks = {
1725
'red': {
1826
'name' : 'red',

0 commit comments

Comments
 (0)