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>2022-05-09 19:26:35 +0300
committerGitHub <noreply@github.com>2022-05-09 19:26:35 +0300
commit5baa4a7c64319485604982f9060702a7cee8a85c (patch)
tree55ce901dbe1db23e519a703dac66e1b3f1142b3b /test
parent86f443e97aa58c1a06b8eb6f523656274234bb71 (diff)
fix: consolidate bugs, docs, repo command logic (#4857)
All three of these commands do the same thing: open a manifest and find a url inside to open it. The finding of that manifest was not very consistent across these three commands. Some work with workspaces while others don't. Some work correctly with `--prefix` while others don't. This PR consolidates these commands so that they all are consistent in how they find the manifest being referenced. The specifics of which url they open are still left to each command. The util that only these three commands were using was consolidated into their base class.
Diffstat (limited to 'test')
-rw-r--r--test/lib/commands/docs.js13
-rw-r--r--test/lib/utils/hosted-git-info-from-manifest.js21
2 files changed, 9 insertions, 25 deletions
diff --git a/test/lib/commands/docs.js b/test/lib/commands/docs.js
index a3b31bd70..b2a65786b 100644
--- a/test/lib/commands/docs.js
+++ b/test/lib/commands/docs.js
@@ -35,6 +35,13 @@ const pkgDirs = t.testdir({
repository: { url: 'https://github.com/foo/repoobj' },
}),
},
+ repourlobj: {
+ 'package.json': JSON.stringify({
+ name: 'repourlobj',
+ version: '1.2.3',
+ repository: { url: { works: false } },
+ }),
+ },
workspaces: {
'package.json': JSON.stringify({
name: 'workspaces-test',
@@ -81,14 +88,13 @@ const docs = new Docs(npm)
t.afterEach(() => opened = {})
t.test('open docs urls', t => {
- // XXX It is very odd that `where` is how pacote knows to look anywhere other
- // than the cwd. I would think npm.localPrefix would factor in somehow
- flatOptions.where = pkgDirs
+ npm.localPrefix = pkgDirs
const expect = {
nodocs: 'https://www.npmjs.com/package/nodocs',
docsurl: 'https://bugzilla.localhost/docsurl',
repourl: 'https://github.com/foo/repourl#readme',
repoobj: 'https://github.com/foo/repoobj#readme',
+ repourlobj: 'https://www.npmjs.com/package/repourlobj',
'.': 'https://example.com',
}
const keys = Object.keys(expect)
@@ -110,7 +116,6 @@ t.test('open default package if none specified', async t => {
})
t.test('workspaces', (t) => {
- flatOptions.where = undefined
npm.localPrefix = join(pkgDirs, 'workspaces')
t.test('all workspaces', async t => {
await docs.execWorkspaces([], [])
diff --git a/test/lib/utils/hosted-git-info-from-manifest.js b/test/lib/utils/hosted-git-info-from-manifest.js
deleted file mode 100644
index 516d3d586..000000000
--- a/test/lib/utils/hosted-git-info-from-manifest.js
+++ /dev/null
@@ -1,21 +0,0 @@
-const t = require('tap')
-const hostedFromMani = require('../../../lib/utils/hosted-git-info-from-manifest.js')
-const hostedGitInfo = require('hosted-git-info')
-
-t.equal(hostedFromMani({}), null)
-t.equal(hostedFromMani({ repository: { no: 'url' } }), null)
-t.equal(hostedFromMani({ repository: 123 }), null)
-t.equal(hostedFromMani({ repository: 'not hosted anywhere' }), null)
-t.equal(hostedFromMani({ repository: { url: 'not hosted anywhere' } }), null)
-
-t.match(hostedFromMani({
- repository: 'git+https://github.com/isaacs/abbrev-js',
-}), hostedGitInfo.fromUrl('git+https://github.com/isaacs/abbrev-js'))
-
-t.match(hostedFromMani({
- repository: { url: 'git+https://github.com/isaacs/abbrev-js' },
-}), hostedGitInfo.fromUrl('https://github.com/isaacs/abbrev-js'))
-
-t.match(hostedFromMani({
- repository: { url: 'git+ssh://git@github.com/isaacs/abbrev-js' },
-}), hostedGitInfo.fromUrl('ssh://git@github.com/isaacs/abbrev-js'))