From d60a9fcd4482000c2387c35b5d60e10fae3cec65 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 21 Jan 2019 22:36:01 +0100 Subject: [PATCH] src: remove has_experimental_policy option This would be set when `--experimental-policy` was set, but since an empty string does not refer to a valid file, we can just check the value of `--experimental-policy` directly. --- lib/internal/bootstrap/node.js | 4 ++-- lib/internal/modules/cjs/loader.js | 2 +- src/node_options.cc | 4 ---- src/node_options.h | 1 - 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index dec4f12ea6ba99..f69932948ca6e5 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -180,10 +180,10 @@ function startup() { } // TODO(joyeecheung): move this down further to get better snapshotting - if (getOptionValue('[has_experimental_policy]')) { + const experimentalPolicy = getOptionValue('--experimental-policy'); + if (experimentalPolicy) { process.emitWarning('Policies are experimental.', 'ExperimentalWarning'); - const experimentalPolicy = getOptionValue('--experimental-policy'); const { pathToFileURL, URL } = NativeModule.require('url'); // URL here as it is slightly different parsing // no bare specifiers for now diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 1dcf5ef6acdaf1..8b357e5254ce4b 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -45,7 +45,7 @@ const { getOptionValue } = require('internal/options'); const preserveSymlinks = getOptionValue('--preserve-symlinks'); const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main'); const experimentalModules = getOptionValue('--experimental-modules'); -const manifest = getOptionValue('[has_experimental_policy]') ? +const manifest = getOptionValue('--experimental-policy') ? require('internal/process/policy').manifest : null; diff --git a/src/node_options.cc b/src/node_options.cc index a3a5e0233aa67c..28c6438a1575f2 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -127,15 +127,11 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { "experimental ES Module support and caching modules", &EnvironmentOptions::experimental_modules, kAllowedInEnvironment); - AddOption("[has_experimental_policy]", - "", - &EnvironmentOptions::has_experimental_policy); AddOption("--experimental-policy", "use the specified file as a " "security policy", &EnvironmentOptions::experimental_policy, kAllowedInEnvironment); - Implies("--experimental-policy", "[has_experimental_policy]"); AddOption("--experimental-repl-await", "experimental await keyword support in REPL", &EnvironmentOptions::experimental_repl_await, diff --git a/src/node_options.h b/src/node_options.h index d77c4fb80877e6..82c2b6e385275a 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -95,7 +95,6 @@ class EnvironmentOptions : public Options { bool abort_on_uncaught_exception = false; bool experimental_modules = false; std::string experimental_policy; - bool has_experimental_policy; bool experimental_repl_await = false; bool experimental_vm_modules = false; bool expose_internals = false;