Skip to content

Commit

Permalink
fixup! src: consolidate exit codes in the code base
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Sep 28, 2022
1 parent fa76b0d commit b439af8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
9 changes: 6 additions & 3 deletions lib/internal/debugger/inspect.js
Expand Up @@ -44,9 +44,12 @@ const { 0: InspectClient, 1: createRepl } =
const debuglog = util.debuglog('inspect');

const { ERR_DEBUGGER_STARTUP_ERROR } = require('internal/errors').codes;
const { exitCodes: {
kGenericUserError, kNoFailure
} } = internalBinding('errors');
const {
exitCodes: {
kGenericUserError,
kNoFailure,
},
} = internalBinding('errors');

async function portIsFree(host, port, timeout = 3000) {
if (port === 0) return; // Binding to a random port.
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/main/watch_mode.js
Expand Up @@ -14,7 +14,7 @@ const {
} = require('internal/process/pre_execution');
const {
triggerUncaughtException,
exitCodes: { kNoFailure }
exitCodes: { kNoFailure },
} = internalBinding('errors');
const { getOptionValue } = require('internal/options');
const { emitExperimentalWarning } = require('internal/util');
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/process/promises.js
Expand Up @@ -25,7 +25,7 @@ const { deprecate } = require('internal/util');
const {
noSideEffectsToString,
triggerUncaughtException,
exitCodes: { kGenericUserError }
exitCodes: { kGenericUserError },
} = internalBinding('errors');

const {
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks.cc
Expand Up @@ -53,7 +53,7 @@ Maybe<bool> EmitProcessBeforeExit(Environment* env) {
Nothing<bool>() : Just(true);
}

ExitCode EmitExitInternal(Environment* env) {
static ExitCode EmitExitInternal(Environment* env) {
return EmitProcessExitInternal(env).FromMaybe(ExitCode::kGenericUserError);
}

Expand Down
5 changes: 3 additions & 2 deletions src/env.cc
Expand Up @@ -1521,8 +1521,9 @@ void Environment::Exit(ExitCode exit_code) {
uv_os_getpid(), thread_id());
}

fprintf(
stderr, "WARNING: Exited the environment with code %d\n", exit_code);
fprintf(stderr,
"WARNING: Exited the environment with code %d\n",
static_cast<int>(exit_code));
PrintStackTrace(isolate(),
StackTrace::CurrentStackTrace(
isolate(), stack_trace_limit(), StackTrace::kDetailed));
Expand Down
20 changes: 10 additions & 10 deletions src/node.cc
Expand Up @@ -626,10 +626,10 @@ void ResetStdio() {
#endif // __POSIX__
}

ExitCode ProcessGlobalArgsInternal(std::vector<std::string>* args,
std::vector<std::string>* exec_args,
std::vector<std::string>* errors,
OptionEnvvarSettings settings) {
static ExitCode ProcessGlobalArgsInternal(std::vector<std::string>* args,
std::vector<std::string>* exec_args,
std::vector<std::string>* errors,
OptionEnvvarSettings settings) {
// Parse a few arguments which are specific to Node.
std::vector<std::string> v8_args;

Expand Down Expand Up @@ -717,7 +717,7 @@ static std::atomic_bool init_called{false};

// TODO(addaleax): Turn this into a wrapper around InitializeOncePerProcess()
// (with the corresponding additional flags set), then eventually remove this.
ExitCode InitializeNodeWithArgsInternal(
static ExitCode InitializeNodeWithArgsInternal(
std::vector<std::string>* argv,
std::vector<std::string>* exec_argv,
std::vector<std::string>* errors,
Expand Down Expand Up @@ -839,10 +839,10 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv,
InitializeNodeWithArgsInternal(argv, exec_argv, errors, flags));
}

std::unique_ptr<InitializationResultImpl> InitializeOncePerProcessInternal(
const std::vector<std::string>& args,
ProcessInitializationFlags::Flags flags =
ProcessInitializationFlags::kNoFlags) {
static std::unique_ptr<InitializationResultImpl>
InitializeOncePerProcessInternal(const std::vector<std::string>& args,
ProcessInitializationFlags::Flags flags =
ProcessInitializationFlags::kNoFlags) {
auto result = std::make_unique<InitializationResultImpl>();
result->args_ = args;

Expand Down Expand Up @@ -1165,7 +1165,7 @@ ExitCode LoadSnapshotDataAndRun(const SnapshotData** snapshot_data_ptr,
return exit_code;
}

ExitCode StartInternal(int argc, char** argv) {
static ExitCode StartInternal(int argc, char** argv) {
CHECK_GT(argc, 0);

// Hack around with the argv pointer. Used for process.title = "blah".
Expand Down

0 comments on commit b439af8

Please sign in to comment.