Robustly extracts an error message string from an unknown error object.
(error: unknown)
| 177 | await ChildProcess.spawnInteractive('npm', args); |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * Log out of NPM at a provided registry. |
| 182 | * @returns Whether the user was logged out of NPM. |
| 183 | */ |
| 184 | static async logout(registryUrl: string | undefined): Promise<boolean> { |
| 185 | const args = ['logout']; |
| 186 | // If a custom registry URL has been specified, add the `--registry` flag. The `--registry` flag |
| 187 | // must be spliced into the correct place in the command as npm expects it to be the flag |
| 188 | // immediately following the logout subcommand. |
| 189 | if (registryUrl !== undefined) { |
| 190 | args.splice(1, 0, '--registry', registryUrl); |
| 191 | } |
| 192 | try { |
| 193 | await ChildProcess.spawn('npm', args, {mode: 'silent'}); |
| 194 | } finally { |
| 195 | return this.checkIsLoggedIn(registryUrl); |
| 196 | } |
| 197 | } |
| 198 | } |
no outgoing calls
no test coverage detected