Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-05-07 19:41:55 +0300
committerGar <gar+gh@danger.computer>2021-05-11 00:04:17 +0300
commit0696fca13d10726e04ca97ff50eef7bd7455a3ab (patch)
tree8d733f67efbdba5232b6cb47bf5ee2454525580f /test
parentf3a662fcd869653f9753aef3d40cc96ed28ed509 (diff)
fix(view): fix non-registry specs
This was working by coincidence in 7.7.6 and before, and broken in the 7.8.0 refactor. Before, it would see there was no "name" in the spec, and then read your local package.json, and from that get a latest tag. So, if you didn't have a package.json in your CWD it would fail with an ENOENT trying to read it. This fixes it for real, so that if you are asking for info from a git spec, it goes ahead and looks for the `latest` tag (or whatever tag you have configured as your default). PR-URL: https://github.com/npm/cli/pull/3209 Credit: @wraithgar Close: #3209 Reviewed-by: @ruyadorno
Diffstat (limited to 'test')
-rw-r--r--test/lib/view.js28
1 files changed, 24 insertions, 4 deletions
diff --git a/test/lib/view.js b/test/lib/view.js
index 3816ce023..4544d7d5d 100644
--- a/test/lib/view.js
+++ b/test/lib/view.js
@@ -34,7 +34,9 @@ const packument = (nv, opts) => {
},
blue: {
name: 'blue',
- 'dist-tags': {},
+ 'dist-tags': {
+ latest: '1.0.0',
+ },
time: {
'1.0.0': '2019-08-06T16:21:09.842Z',
},
@@ -59,7 +61,9 @@ const packument = (nv, opts) => {
email: 'claudia@cyan.com',
},
name: 'cyan',
- 'dist-tags': {},
+ 'dist-tags': {
+ latest: '1.0.0',
+ },
versions: {
'1.0.0': {
version: '1.0.0',
@@ -236,6 +240,8 @@ const packument = (nv, opts) => {
},
},
}
+ if (nv.type === 'git')
+ return mocks[nv.hosted.project]
return mocks[nv.name]
}
@@ -258,7 +264,10 @@ t.test('should log package info', t => {
},
})
const jsonNpm = mockNpm({
- config: { json: true },
+ config: {
+ json: true,
+ tag: 'latest',
+ },
})
const viewJson = new ViewJson(jsonNpm)
@@ -272,6 +281,13 @@ t.test('should log package info', t => {
})
const viewUnicode = new ViewUnicode(unicodeNpm)
+ t.test('package from git', t => {
+ view.exec(['https://github.com/npm/green'], () => {
+ t.matchSnapshot(logs)
+ t.end()
+ })
+ })
+
t.test('package with license, bugs, repository and other fields', t => {
view.exec(['green@1.0.0'], () => {
t.matchSnapshot(logs)
@@ -384,6 +400,7 @@ t.test('should log info by field name', t => {
})
const jsonNpm = mockNpm({
config: {
+ tag: 'latest',
json: true,
},
})
@@ -467,7 +484,10 @@ t.test('should log info by field name', t => {
t.test('throw error if global mode', (t) => {
const View = t.mock('../../lib/view.js')
const npm = mockNpm({
- config: { global: true },
+ config: {
+ global: true,
+ tag: 'latest',
+ },
})
const view = new View(npm)
view.exec([], (err) => {