diff --git a/lib/commands/view.js b/lib/commands/view.js index 0c3f232602f87..6537e05c10fb0 100644 --- a/lib/commands/view.js +++ b/lib/commands/view.js @@ -103,6 +103,7 @@ class View extends BaseCommand { // put the version back if it existed pkg = `${manifest.name}${pkg.slice(1)}` } + let wholePackument = false if (!args.length) { args = [''] @@ -196,7 +197,7 @@ class View extends BaseCommand { // get the data about this package let version = this.npm.config.get('tag') // rawSpec is the git url if this is from git - if (spec.type !== 'git' && spec.rawSpec) { + if (spec.type !== 'git' && spec.type !== 'directory' && spec.rawSpec) { version = spec.rawSpec } @@ -205,7 +206,6 @@ class View extends BaseCommand { if (pckmnt['dist-tags'] && pckmnt['dist-tags'][version]) { version = pckmnt['dist-tags'][version] } - if (pckmnt.time && pckmnt.time.unpublished) { const u = pckmnt.time.unpublished const er = new Error('Unpublished by ' + u.name + ' on ' + u.time) diff --git a/tap-snapshots/test/lib/commands/view.js.test.cjs b/tap-snapshots/test/lib/commands/view.js.test.cjs index 72d09b44e2620..229a9d323dbae 100644 --- a/tap-snapshots/test/lib/commands/view.js.test.cjs +++ b/tap-snapshots/test/lib/commands/view.js.test.cjs @@ -68,6 +68,23 @@ yellow@1.0.1 'claudia' yellow@1.0.2 'claudia' ` +exports[`test/lib/commands/view.js TAP should log info of package in current working dir directory > must match snapshot 1`] = ` + + +blue@1.0.0 | Proprietary | deps: none | versions: 2 + +dist +.tarball:http://hm.blue.com/1.0.0.tgz +.shasum:123 +.integrity:--- +.unpackedSize:1 B + +dist-tags: +latest: 1.0.0 + +published {TIME} ago +` + exports[`test/lib/commands/view.js TAP should log info of package in current working dir non-specific version > must match snapshot 1`] = ` diff --git a/test/lib/commands/view.js b/test/lib/commands/view.js index 035490a79fbf7..2fde7a4c71f20 100644 --- a/test/lib/commands/view.js +++ b/test/lib/commands/view.js @@ -262,6 +262,9 @@ const packument = (nv, opts) => { if (nv.type === 'git') { return mocks[nv.hosted.project] } + if (nv.raw === './blue') { + return mocks.blue + } return mocks[nv.name] } @@ -387,6 +390,11 @@ t.test('should log info of package in current working dir', async t => { await view.exec(['.']) t.matchSnapshot(logs) }) + + t.test('directory', async t => { + await view.exec(['./blue']) + t.matchSnapshot(logs) + }) }) t.test('should log info by field name', async t => {