(code)
| 65 | } |
| 66 | |
| 67 | #handleProcessExit (code) { |
| 68 | const numCode = Number(code) || 0 |
| 69 | // Always exit w/ a non-zero code if exit handler was not called |
| 70 | const exitCode = this.#exited ? numCode : (numCode || 1) |
| 71 | this.#process.exitCode = exitCode |
| 72 | |
| 73 | if (this.#notLoadedOrExited) { |
| 74 | // Exit handler was not called and npm was not loaded so we have to log something |
| 75 | this.#logConsoleError(new Error(`Process exited unexpectedly with code: ${exitCode}`)) |
| 76 | return |
| 77 | } |
| 78 | |
| 79 | if (this.#logNoNpmError()) { |
| 80 | return |
| 81 | } |
| 82 | |
| 83 | const os = require('node:os') |
| 84 | log.verbose('cwd', this.#process.cwd()) |
| 85 | log.verbose('os', `${os.type()} ${os.release()}`) |
| 86 | log.verbose('node', this.#process.version) |
| 87 | log.verbose('npm ', `v${this.#npm.version}`) |
| 88 | |
| 89 | // only show the notification if it finished |
| 90 | if (typeof this.#npm.updateNotification === 'string') { |
| 91 | log.notice('', this.#npm.updateNotification, { [META]: true, force: true }) |
| 92 | } |
| 93 | |
| 94 | if (!this.#exited) { |
| 95 | log.error('', 'Exit handler never called!') |
| 96 | log.error('', 'This is an error with npm itself. Please report this error at:') |
| 97 | log.error('', ' <https://github.com/npm/cli/issues>') |
| 98 | if (this.#npm.silent) { |
| 99 | output.error('') |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | log.verbose('exit', exitCode) |
| 104 | |
| 105 | if (exitCode) { |
| 106 | log.verbose('code', exitCode) |
| 107 | } else { |
| 108 | log.info('ok') |
| 109 | } |
| 110 | |
| 111 | if (this.#showExitErrorMessage) { |
| 112 | log.error('', this.#npm.exitErrorMessage()) |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | #logConsoleError (err) { |
| 117 | // Run our error message formatters on all errors even if we have no npm or an unloaded npm. |
no test coverage detected