From 0a32a0c58aea09ce3de977df500937e88a301c0f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 9 Aug 2021 17:03:41 +0900 Subject: [PATCH] build: add option to hide console window --- configure.py | 7 +++++++ node.gypi | 3 +++ src/process_wrap.cc | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/configure.py b/configure.py index 9327d6e5f5da06..428316cf588634 100755 --- a/configure.py +++ b/configure.py @@ -710,6 +710,12 @@ help='do not export browser globals like setTimeout, console, etc. ' + '(This mode is not officially supported for regular applications)') +parser.add_argument('--hide-console-window', + action='store_true', + dest='hide_console_window', + default=None, + help='always hide console window when spawning new processes on Windows') + parser.add_argument('--without-inspector', action='store_true', dest='without_inspector', @@ -1305,6 +1311,7 @@ def configure_node(o): o['variables']['debug_nghttp2'] = 'false' o['variables']['node_no_browser_globals'] = b(options.no_browser_globals) + o['variables']['node_hide_console_window'] = b(options.hide_console_window) o['variables']['node_shared'] = b(options.shared) node_module_version = getmoduleversion.get_version() diff --git a/node.gypi b/node.gypi index 713ddbb74a1b8e..1b485a29eb5468 100644 --- a/node.gypi +++ b/node.gypi @@ -115,6 +115,9 @@ [ 'node_no_browser_globals=="true"', { 'defines': [ 'NODE_NO_BROWSER_GLOBALS' ], } ], + [ 'node_hide_console_window=="true"', { + 'defines': [ 'NODE_HIDE_CONSOLE_WINDOW' ], + } ], [ 'node_shared_zlib=="false"', { 'dependencies': [ 'deps/zlib/zlib.gyp:zlib' ], 'conditions': [ diff --git a/src/process_wrap.cc b/src/process_wrap.cc index 45920c2603b179..e0f33846c53e9c 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -238,6 +238,10 @@ class ProcessWrap : public HandleWrap { options.flags |= UV_PROCESS_WINDOWS_HIDE; } +#if defined(NODE_HIDE_CONSOLE_WINDOW) + options.flags |= UV_PROCESS_WINDOWS_HIDE_CONSOLE; +#endif + // options.windows_verbatim_arguments Local wva_v = js_options->Get(context, env->windows_verbatim_arguments_string())