diff --git a/lib/commands/help.js b/lib/commands/help.js index d520dd1cceb45..1b7d0e9a4921d 100644 --- a/lib/commands/help.js +++ b/lib/commands/help.js @@ -87,7 +87,7 @@ class Help extends BaseCommand { return openUrl(this.npm, this.htmlMan(man), 'help available at the following URL', true) } - let args = ['man', [man]] + let args = [viewer, [man]] if (viewer === 'woman') { args = ['emacsclient', ['-e', `(woman-find-file '${man}')`]] } diff --git a/test/lib/commands/help.js b/test/lib/commands/help.js index 77d05d7b5048c..2461c5a90b469 100644 --- a/test/lib/commands/help.js +++ b/test/lib/commands/help.js @@ -111,6 +111,18 @@ t.test('npm help whoami', async t => { t.match(spawnArgs[0], /npm-whoami\.1$/) }) +t.test('npm help with custom viewer', async t => { + const { getArgs } = await mockHelp(t, { + exec: ['whoami'], + config: { viewer: 'batman' }, + }) + + const [spawnBin, spawnArgs] = getArgs() + t.equal(spawnBin, 'batman', 'calls the configured viewer') + t.equal(spawnArgs.length, 1) + t.match(spawnArgs[0], /npm-whoami\.1$/) +}) + t.test('npm help 1 install', async t => { const { getArgs } = await mockHelp(t, { exec: ['1', 'install'],