diff options
-rw-r--r-- | docs/content/commands/npm-bugs.md | 6 | ||||
-rw-r--r-- | lib/bugs.js | 3 | ||||
-rw-r--r-- | test/lib/bugs.js | 14 |
3 files changed, 19 insertions, 4 deletions
diff --git a/docs/content/commands/npm-bugs.md b/docs/content/commands/npm-bugs.md index dd1ab299f..714db4440 100644 --- a/docs/content/commands/npm-bugs.md +++ b/docs/content/commands/npm-bugs.md @@ -15,9 +15,9 @@ aliases: issues ### Description This command tries to guess at the likely location of a package's bug -tracker URL, and then tries to open it using the `--browser` config param. -If no package name is provided, it will search for a `package.json` in the -current folder and use the `name` property. +tracker URL or the `mailto` URL of the support email, and then tries to +open it using the `--browser` config param. If no package name is provided, it +will search for a `package.json` in the current folder and use the `name` property. ### Configuration diff --git a/lib/bugs.js b/lib/bugs.js index a0cef4c5e..5085a25b4 100644 --- a/lib/bugs.js +++ b/lib/bugs.js @@ -43,6 +43,9 @@ class Bugs extends BaseCommand { if (typeof mani.bugs === 'object' && mani.bugs.url) return mani.bugs.url + + if (typeof mani.bugs === 'object' && mani.bugs.email) + return `mailto:${mani.bugs.email}` } // try to get it from the repo, if possible diff --git a/test/lib/bugs.js b/test/lib/bugs.js index 1cc6e06ee..e5b238ffc 100644 --- a/test/lib/bugs.js +++ b/test/lib/bugs.js @@ -31,6 +31,16 @@ const pacote = { version: '1.2.3', repository: { url: 'https://github.com/foo/repoobj' }, } + : spec === 'mailtest' ? { + name: 'mailtest', + version: '3.7.4', + bugs: { email: 'hello@example.com' }, + } + : spec === 'secondmailtest' ? { + name: 'secondmailtest', + version: '0.1.1', + bugs: { email: 'ABC432abc@a.b.example.net' }, + } : spec === '.' ? { name: 'thispkg', version: '1.2.3', @@ -59,7 +69,7 @@ t.test('usage', (t) => { t.end() }) -t.test('open bugs urls', t => { +t.test('open bugs urls & emails', t => { const expect = { nobugs: 'https://www.npmjs.com/package/nobugs', 'bugsobj-nourl': 'https://www.npmjs.com/package/bugsobj-nourl', @@ -67,6 +77,8 @@ t.test('open bugs urls', t => { bugsobj: 'https://bugzilla.localhost/bugsobj', repourl: 'https://github.com/foo/repourl/issues', repoobj: 'https://github.com/foo/repoobj/issues', + mailtest: 'mailto:hello@example.com', + secondmailtest: 'mailto:ABC432abc@a.b.example.net', '.': 'https://example.com', } const keys = Object.keys(expect) |