Disallow nested '.env' blocks since they are useless.

This commit is contained in:
Logan Smyth 2017-11-22 18:23:28 -08:00
parent a89171910f
commit db28c18458
2 changed files with 3 additions and 8 deletions

View File

@ -206,6 +206,9 @@ export function validate(type: OptionsType, opts: {}): ValidatedOptions {
if (type !== "arguments" && ROOT_VALIDATORS[key]) { if (type !== "arguments" && ROOT_VALIDATORS[key]) {
throw new Error(`.${key} is only allowed in root programmatic options`); throw new Error(`.${key} is only allowed in root programmatic options`);
} }
if (type === "env" && key === "env") {
throw new Error(`.${key} is not allowed inside another env block`);
}
const validator = const validator =
COMMON_VALIDATORS[key] || COMMON_VALIDATORS[key] ||

View File

@ -296,12 +296,6 @@ describe("api", function() {
development: { development: {
passPerPreset: true, passPerPreset: true,
presets: [pushPreset("argthree"), pushPreset("argfour")], presets: [pushPreset("argthree"), pushPreset("argfour")],
env: {
development: {
passPerPreset: true,
presets: [pushPreset("argfive"), pushPreset("argsix")],
},
},
}, },
}, },
}); });
@ -327,8 +321,6 @@ describe("api", function() {
"fourteen;", "fourteen;",
"fifteen;", "fifteen;",
"sixteen;", "sixteen;",
"argfive;",
"argsix;",
"argthree;", "argthree;",
"argfour;", "argfour;",
"seven;", "seven;",