Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

view: always fetch fullMetadata, and preferOnline #1757

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions lib/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const completion = async (opts, cb) => {
return cb()
}
// have the package, get the fields
const config = npm.flatOptions
const config = { ...npm.flatOptions, fullMetadata: true, preferOnline: true }
const { defaultTag } = config
const spec = npa(opts.conf.argv.remain[2])
const pckmnt = await packument(spec, config)
Expand Down Expand Up @@ -63,7 +63,7 @@ const completion = async (opts, cb) => {
const view = async args => {
if (!args.length) args = ['.']

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

const pckmnt = await packument(nv, {
...opts,
fullMetadata: true,
'prefer-online': true
})
const pckmnt = await packument(nv, opts)

if (pckmnt['dist-tags'] && pckmnt['dist-tags'][version]) {
version = pckmnt['dist-tags'][version]
Expand Down
10 changes: 9 additions & 1 deletion test/lib/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ const cleanLogs = (done) => {
done()
}

const packument = (nv) => {
const packument = (nv, opts) => {
if (!opts.fullMetadata) {
throw new Error('must fetch fullMetadata')
}

if (!opts.preferOnline) {
throw new Error('must fetch with preferOnline')
}

const mocks = {
'red': {
'name' : 'red',
Expand Down