Skip to content

Commit

Permalink
build: add option to hide console window
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Aug 30, 2021
1 parent 343e43d commit 1d7214b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 40 deletions.
1 change: 0 additions & 1 deletion patches/node/.patches
@@ -1,5 +1,4 @@
make_module_globalpaths_a_reference.patch
fix_don_t_create_console_window_when_creating_process.patch
refactor_alter_child_process_fork_to_use_execute_script_with.patch
feat_add_uv_loop_watcher_queue_code.patch
feat_initialize_asar_support.patch
Expand Down
28 changes: 14 additions & 14 deletions patches/node/fix_allow_preventing_initializeinspector_in_env.patch
Expand Up @@ -36,11 +36,11 @@ index de29d45adde76587f2a9cd50392ba45b8e24839e..09c0d22ff91856704f61024646c946a3
#endif

diff --git a/src/env-inl.h b/src/env-inl.h
index b3b1ea908253b9240cc37931f34b2a8c8c9fa3ab..dc37298aa0e13bb79030123f38070d0254691b28 100644
index 061897d95d8b5f61968c59260e609d7be724b88f..7c7ee3207089bf3e51db646a367bdd6deba18628 100644
--- a/src/env-inl.h
+++ b/src/env-inl.h
@@ -877,6 +877,10 @@ inline bool Environment::tracks_unmanaged_fds() const {
return flags_ & EnvironmentFlags::kTrackUnmanagedFds;
@@ -881,6 +881,10 @@ inline bool Environment::hide_console_windows() const {
return flags_ & EnvironmentFlags::kHideConsoleWindows;
}

+inline bool Environment::should_initialize_inspector() const {
Expand All @@ -51,31 +51,31 @@ index b3b1ea908253b9240cc37931f34b2a8c8c9fa3ab..dc37298aa0e13bb79030123f38070d02
return emit_filehandle_warning_;
}
diff --git a/src/env.h b/src/env.h
index 24b4a48b5f9657cc115aaa50e0f7354534ed5484..0877f5b1fe2db42acf908e0e1085626fc258ef54 100644
index 8760bc4361f199a2e3471c4ca435f8e178c78e7e..33f34ed79452b004b5fb40e70cda6e3d0ee2d1e2 100644
--- a/src/env.h
+++ b/src/env.h
@@ -1198,6 +1198,7 @@ class Environment : public MemoryRetainer {
inline bool owns_process_state() const;
@@ -1199,6 +1199,7 @@ class Environment : public MemoryRetainer {
inline bool owns_inspector() const;
inline bool tracks_unmanaged_fds() const;
inline bool hide_console_windows() const;
+ inline bool should_initialize_inspector() const;
inline uint64_t thread_id() const;
inline worker::Worker* worker_context() const;
Environment* worker_parent_env() const;
diff --git a/src/node.h b/src/node.h
index 41f79ef869128636ac04093919e8e5816b39bef9..691c16ba60b0ce8633555825e44c3ace96c5000f 100644
index b7f3e97873ef90b635e0648639f1a287a0bd88fa..48e378079f6d05e7cc1141a8875450b125028789 100644
--- a/src/node.h
+++ b/src/node.h
@@ -405,7 +405,11 @@ enum Flags : uint64_t {
kNoRegisterESMLoader = 1 << 3,
// Set this flag to make Node.js track "raw" file descriptors, i.e. managed
// by fs.open() and fs.close(), and close them during FreeEnvironment().
- kTrackUnmanagedFds = 1 << 4
+ kTrackUnmanagedFds = 1 << 4,
@@ -409,7 +409,11 @@ enum Flags : uint64_t {
// Set this flag to force hiding console windows when spawning child
// processes. This is usually used when embedding Node.js in GUI programs on
// Windows.
- kHideConsoleWindows = 1 << 5
+ kHideConsoleWindows = 1 << 5,
+ // Controls whether or not the Environment should call InitializeInspector.
+ // This control is needed by embedders who may not want to initialize the V8
+ // inspector in situations where it already exists.
+ kNoInitializeInspector = 1 << 5
+ kNoInitializeInspector = 1 << 6
};
} // namespace EnvironmentFlags

This file was deleted.

12 changes: 8 additions & 4 deletions shell/common/node_bindings.cc
Expand Up @@ -450,13 +450,15 @@ node::Environment* NodeBindings::CreateEnvironment(
node::CreateIsolateData(context->GetIsolate(), uv_loop_, platform);

node::Environment* env;
uint64_t flags = node::EnvironmentFlags::kDefaultFlags |
node::EnvironmentFlags::kHideConsoleWindows;

if (browser_env_ != BrowserEnvironment::kBrowser) {
// Only one ESM loader can be registered per isolate -
// in renderer processes this should be blink. We need to tell Node.js
// not to register its handler (overriding blinks) in non-browser processes.
uint64_t flags = node::EnvironmentFlags::kDefaultFlags |
node::EnvironmentFlags::kNoRegisterESMLoader |
node::EnvironmentFlags::kNoInitializeInspector;
flags |= node::EnvironmentFlags::kNoRegisterESMLoader |
node::EnvironmentFlags::kNoInitializeInspector;
v8::TryCatch try_catch(context->GetIsolate());
env = node::CreateEnvironment(
isolate_data_, context, args, exec_args,
Expand All @@ -470,7 +472,9 @@ node::Environment* NodeBindings::CreateEnvironment(
<< process_type;
}
} else {
env = node::CreateEnvironment(isolate_data_, context, args, exec_args);
env = node::CreateEnvironment(
isolate_data_, context, args, exec_args,
static_cast<node::EnvironmentFlags::Flags>(flags));
DCHECK(env);
}

Expand Down

0 comments on commit 1d7214b

Please sign in to comment.