Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,11 @@ var spawn = exports.spawn = function spawn(/* file, args, options */) {
var options = opts.options;
var child = new ChildProcess();

// If run with the --windows-hide flag, hide spawned windows by default.
const windowsHideFlag = process.binding('config').windowsHide;
if (options.windowsHide === undefined && windowsHideFlag)
options.windowsHide = true;

debug('spawn', opts.args, options);

child.spawn({
Expand Down
8 changes: 8 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ std::string config_warning_file; // NOLINT(runtime/string)
// that is used by lib/internal/bootstrap/node.js
bool config_expose_internals = false;

// Set in node.cc by ParseArgs when --windows-hide is used.
// Used in node_config.cc to set a constant on process.binding('config') that
// is used by lib/child_process.js
bool config_windows_hide

bool v8_initialized = false;

bool linux_at_secure = false;
Expand Down Expand Up @@ -3184,6 +3189,7 @@ static void CheckIfAllowedInEnv(const char* exe, bool is_env,
"--v8-pool-size",
"--zero-fill-buffers",
"-r",
"--windows-hide",

// V8 options (define with '_', which allows '-' or '_')
"--abort_on_uncaught_exception",
Expand Down Expand Up @@ -3418,6 +3424,8 @@ static void ParseArgs(int* argc,
// Also a V8 option. Pass through as-is.
new_v8_argv[new_v8_argc] = arg;
new_v8_argc += 1;
} else if (strcmp(arg, "--windows-hide") == 0) {
config_windows_hide = true;
} else {
// V8 option. Pass through as-is.
new_v8_argv[new_v8_argc] = arg;
Expand Down
3 changes: 3 additions & 0 deletions src/node_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ static void Initialize(Local<Object> target,
if (config_expose_internals)
READONLY_BOOLEAN_PROPERTY("exposeInternals");

if (config_windows_hide)
READONLY_BOOLEAN_PROPERTY("windowsHide")

if (env->abort_on_uncaught_exception())
READONLY_BOOLEAN_PROPERTY("shouldAbortOnUncaughtException");

Expand Down