| 104 | .join('] [')}]`] |
| 105 | |
| 106 | async exec (args) { |
| 107 | log.info('doctor', 'Running checkup') |
| 108 | let allOk = true |
| 109 | |
| 110 | const actions = this.actions(args) |
| 111 | |
| 112 | const chalk = this.npm.chalk |
| 113 | for (const { title, cmd } of actions) { |
| 114 | this.output(title) |
| 115 | // TODO when we have an in progress indicator that could go here |
| 116 | let result |
| 117 | try { |
| 118 | result = await this[cmd]() |
| 119 | this.output(`${chalk.green('Ok')}${result ? `\n${result}` : ''}\n`) |
| 120 | } catch (err) { |
| 121 | allOk = false |
| 122 | this.output(`${chalk.red('Not ok')}\n${chalk.cyan(err)}\n`) |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | if (!allOk) { |
| 127 | if (this.npm.silent) { |
| 128 | throw new Error('Some problems found. Check logs or disable silent mode for recommendations.') |
| 129 | } else { |
| 130 | throw new Error('Some problems found. See above for recommendations.') |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | async checkPing () { |
| 136 | log.info('doctor', 'Pinging registry') |