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.

PR-URL: https://github.com/nodejs/node/pull/25628
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
This commit is contained in:
Anna Henningsen 2019-01-21 22:36:01 +01:00 committed by Daniel Bevenius
parent 0f5c14c43e
commit f8d52c25c4
4 changed files with 3 additions and 8 deletions

View File

@ -180,10 +180,10 @@ function startup() {
} }
// TODO(joyeecheung): move this down further to get better snapshotting // 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.', process.emitWarning('Policies are experimental.',
'ExperimentalWarning'); 'ExperimentalWarning');
const experimentalPolicy = getOptionValue('--experimental-policy');
const { pathToFileURL, URL } = NativeModule.require('url'); const { pathToFileURL, URL } = NativeModule.require('url');
// URL here as it is slightly different parsing // URL here as it is slightly different parsing
// no bare specifiers for now // no bare specifiers for now

View File

@ -45,7 +45,7 @@ const { getOptionValue } = require('internal/options');
const preserveSymlinks = getOptionValue('--preserve-symlinks'); const preserveSymlinks = getOptionValue('--preserve-symlinks');
const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main'); const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main');
const experimentalModules = getOptionValue('--experimental-modules'); const experimentalModules = getOptionValue('--experimental-modules');
const manifest = getOptionValue('[has_experimental_policy]') ? const manifest = getOptionValue('--experimental-policy') ?
require('internal/process/policy').manifest : require('internal/process/policy').manifest :
null; null;

View File

@ -143,15 +143,11 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
"experimental ES Module support and caching modules", "experimental ES Module support and caching modules",
&EnvironmentOptions::experimental_modules, &EnvironmentOptions::experimental_modules,
kAllowedInEnvironment); kAllowedInEnvironment);
AddOption("[has_experimental_policy]",
"",
&EnvironmentOptions::has_experimental_policy);
AddOption("--experimental-policy", AddOption("--experimental-policy",
"use the specified file as a " "use the specified file as a "
"security policy", "security policy",
&EnvironmentOptions::experimental_policy, &EnvironmentOptions::experimental_policy,
kAllowedInEnvironment); kAllowedInEnvironment);
Implies("--experimental-policy", "[has_experimental_policy]");
AddOption("--experimental-repl-await", AddOption("--experimental-repl-await",
"experimental await keyword support in REPL", "experimental await keyword support in REPL",
&EnvironmentOptions::experimental_repl_await, &EnvironmentOptions::experimental_repl_await,

View File

@ -95,7 +95,6 @@ class EnvironmentOptions : public Options {
bool abort_on_uncaught_exception = false; bool abort_on_uncaught_exception = false;
bool experimental_modules = false; bool experimental_modules = false;
std::string experimental_policy; std::string experimental_policy;
bool has_experimental_policy;
bool experimental_repl_await = false; bool experimental_repl_await = false;
bool experimental_vm_modules = false; bool experimental_vm_modules = false;
bool expose_internals = false; bool expose_internals = false;