summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Goldstein <dgoldstein@dropbox.com>2018-04-10 07:40:56 +0000
committerVse Mozhet Byt <vsemozhetbyt@gmail.com>2018-05-13 00:28:16 +0300
commit236596590ce5746c66a36bee9ca81203553bd7a2 (patch)
tree6d077b2859a268a689d30068afa6c28208a22b64 /src
parent20509ebee681233443ebc7dc1b58c2fab6d2b12f (diff)
downloadandroid-node-v8-236596590ce5746c66a36bee9ca81203553bd7a2.tar.gz
android-node-v8-236596590ce5746c66a36bee9ca81203553bd7a2.tar.bz2
android-node-v8-236596590ce5746c66a36bee9ca81203553bd7a2.zip
module: add --preserve-symlinks-main
Add `--preserve-symlinks-main` option which behaves like `--preserve-symlinks` but for `require.main`. PR-URL: https://github.com/nodejs/node/pull/19911 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node.cc16
-rw-r--r--src/node_config.cc2
-rw-r--r--src/node_internals.h5
3 files changed, 22 insertions, 1 deletions
diff --git a/src/node.cc b/src/node.cc
index 6411eafb8c..141846f6a1 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -237,6 +237,11 @@ bool trace_warnings = false;
// that is used by lib/module.js
bool config_preserve_symlinks = false;
+// Set in node.cc by ParseArgs when --preserve-symlinks-main is used.
+// Used in node_config.cc to set a constant on process.binding('config')
+// that is used by lib/module.js
+bool config_preserve_symlinks_main = false;
+
// Set in node.cc by ParseArgs when --experimental-modules is used.
// Used in node_config.cc to set a constant on process.binding('config')
// that is used by lib/module.js
@@ -3529,6 +3534,8 @@ static void PrintHelp() {
" --pending-deprecation emit pending deprecation warnings\n"
#if defined(NODE_HAVE_I18N_SUPPORT)
" --preserve-symlinks preserve symbolic links when resolving\n"
+ " --preserve-symlinks-main preserve symbolic links when resolving\n"
+ " the main module\n"
#endif
" --prof-process process v8 profiler output generated\n"
" using --prof\n"
@@ -3579,7 +3586,6 @@ static void PrintHelp() {
" -r, --require module to preload (option can be "
"repeated)\n"
" -v, --version print Node.js version\n"
-
"\n"
"Environment variables:\n"
"NODE_DEBUG ','-separated list of core modules\n"
@@ -3842,6 +3848,8 @@ static void ParseArgs(int* argc,
Revert(cve);
} else if (strcmp(arg, "--preserve-symlinks") == 0) {
config_preserve_symlinks = true;
+ } else if (strcmp(arg, "--preserve-symlinks-main") == 0) {
+ config_preserve_symlinks_main = true;
} else if (strcmp(arg, "--experimental-modules") == 0) {
config_experimental_modules = true;
new_v8_argv[new_v8_argc] = "--harmony-dynamic-import";
@@ -4286,6 +4294,12 @@ void Init(int* argc,
SafeGetenv("NODE_PRESERVE_SYMLINKS", &text) && text[0] == '1';
}
+ {
+ std::string text;
+ config_preserve_symlinks_main =
+ SafeGetenv("NODE_PRESERVE_SYMLINKS_MAIN", &text) && text[0] == '1';
+ }
+
if (config_warning_file.empty())
SafeGetenv("NODE_REDIRECT_WARNINGS", &config_warning_file);
diff --git a/src/node_config.cc b/src/node_config.cc
index e2b2662abd..603d55491a 100644
--- a/src/node_config.cc
+++ b/src/node_config.cc
@@ -72,6 +72,8 @@ static void Initialize(Local<Object> target,
if (config_preserve_symlinks)
READONLY_BOOLEAN_PROPERTY("preserveSymlinks");
+ if (config_preserve_symlinks_main)
+ READONLY_BOOLEAN_PROPERTY("preserveSymlinksMain");
if (config_experimental_modules) {
READONLY_BOOLEAN_PROPERTY("experimentalModules");
diff --git a/src/node_internals.h b/src/node_internals.h
index 8aa4631880..c10369c563 100644
--- a/src/node_internals.h
+++ b/src/node_internals.h
@@ -173,6 +173,11 @@ extern std::string openssl_config;
// that is used by lib/module.js
extern bool config_preserve_symlinks;
+// Set in node.cc by ParseArgs when --preserve-symlinks-main is used.
+// Used in node_config.cc to set a constant on process.binding('config')
+// that is used by lib/module.js
+extern bool config_preserve_symlinks_main;
+
// Set in node.cc by ParseArgs when --experimental-modules is used.
// Used in node_config.cc to set a constant on process.binding('config')
// that is used by lib/module.js