mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 17:32:22 +00:00

Add an ExitCode enum class and use it throughout the code base instead of hard-coding the exit codes everywhere. At the moment, the exit codes used in many places do not actually conform to what the documentation describes. With the new enums (which are also available to the JS land as constants in an internal binding) we could migrate to a more consistent usage of the codes, and eventually expose the constants to the user land when they are stable enough. PR-URL: https://github.com/nodejs/node/pull/44746 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
15 lines
424 B
JavaScript
15 lines
424 B
JavaScript
'use strict';
|
|
|
|
const { exitCodes: { kUnfinishedTopLevelAwait } } = internalBinding('errors');
|
|
|
|
// Handle a Promise from running code that potentially does Top-Level Await.
|
|
// In that case, it makes sense to set the exit code to a specific non-zero
|
|
// value if the main code never finishes running.
|
|
function handleProcessExit() {
|
|
process.exitCode ??= kUnfinishedTopLevelAwait;
|
|
}
|
|
|
|
module.exports = {
|
|
handleProcessExit,
|
|
};
|