Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/commands/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}')`]]
}
Expand Down
12 changes: 12 additions & 0 deletions test/lib/commands/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down