Expose the envName as a programmatic and CLI option.

This commit is contained in:
Logan Smyth
2017-11-14 23:04:08 -08:00
parent 74439889d8
commit aa2d415507
4 changed files with 14 additions and 2 deletions

View File

@@ -103,7 +103,7 @@ class OptionManager {
init(inputOpts: {}) {
const args = validate("arguments", inputOpts);
const envName = getEnv();
const { envName = getEnv() } = args;
const configChain = buildConfigChain(args, envName);
if (!configChain) return null;
@@ -133,6 +133,7 @@ class OptionManager {
.filter(plugins => plugins.length > 0)
.map(plugins => ({ plugins }));
opts.passPerPreset = opts.presets.length > 0;
opts.envName = envName;
return {
options: opts,

View File

@@ -28,6 +28,10 @@ const ROOT_VALIDATORS: ValidatorSet = {
>),
code: (assertBoolean: Validator<$PropertyType<ValidatedOptions, "code">>),
ast: (assertBoolean: Validator<$PropertyType<ValidatedOptions, "ast">>),
envName: (assertString: Validator<
$PropertyType<ValidatedOptions, "envName">,
>),
};
const NONPRESET_VALIDATORS: ValidatorSet = {
@@ -130,6 +134,7 @@ export type ValidatedOptions = {
code?: boolean,
ast?: boolean,
inputSourceMap?: RootInputSourceMapOption,
envName?: string,
extends?: string,
env?: EnvSet<ValidatedOptions>,