| 80 | } |
| 81 | |
| 82 | async viewMan (man) { |
| 83 | const viewer = this.npm.config.get('viewer') |
| 84 | |
| 85 | if (viewer === 'browser') { |
| 86 | return openUrl(this.npm, this.htmlMan(man), 'help available at the following URL', true) |
| 87 | } |
| 88 | |
| 89 | let args = ['man', [man]] |
| 90 | if (viewer === 'woman') { |
| 91 | args = ['emacsclient', ['-e', `(woman-find-file '${man}')`]] |
| 92 | } |
| 93 | |
| 94 | try { |
| 95 | await input.start(() => spawn(...args, { stdio: 'inherit' })) |
| 96 | } catch (err) { |
| 97 | if (err.code) { |
| 98 | throw new Error(`help process exited with code: ${err.code}`) |
| 99 | } else { |
| 100 | throw err |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | // Returns the path to the html version of the man page |
| 106 | htmlMan (man) { |