feat: cli flags

This commit is contained in:
evilebottnawi 2020-03-10 16:06:37 +03:00 committed by Tobias Koppers
parent f728b209b4
commit c1244f530e
2 changed files with 30 additions and 28 deletions

View File

@ -28,7 +28,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
], ],
description: "Disable caching." description: "Disable caching."
@ -57,7 +57,7 @@ module.exports = {
types: [ types: [
{ {
type: "string", type: "string",
multiple: true multiple: false
} }
], ],
description: "In memory caching" description: "In memory caching"
@ -164,7 +164,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
] ]
}, },
@ -684,7 +684,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
], ],
description: "Include a polyfill for the '__dirname' variable" description: "Include a polyfill for the '__dirname' variable"
@ -693,7 +693,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
], ],
description: "Include a polyfill for the '__filename' variable" description: "Include a polyfill for the '__filename' variable"
@ -721,7 +721,7 @@ module.exports = {
types: [ types: [
{ {
type: "string", type: "string",
multiple: true multiple: false
} }
], ],
description: description:
@ -798,7 +798,7 @@ module.exports = {
types: [ types: [
{ {
type: "string", type: "string",
multiple: true multiple: false
} }
], ],
description: description:
@ -817,7 +817,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
] ]
}, },
@ -864,7 +864,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
] ]
}, },
@ -1053,7 +1053,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
] ]
}, },
@ -1163,7 +1163,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
], ],
description: "This option enables cross-origin loading of chunks." description: "This option enables cross-origin loading of chunks."
@ -1198,7 +1198,7 @@ module.exports = {
types: [ types: [
{ {
type: "number", type: "number",
multiple: true multiple: false
} }
] ]
}, },
@ -1318,7 +1318,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
], ],
description: description:
@ -1589,7 +1589,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
], ],
description: description:
@ -1627,7 +1627,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
] ]
}, },
@ -1635,7 +1635,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
] ]
}, },
@ -1643,7 +1643,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
] ]
}, },
@ -2218,7 +2218,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
], ],
description: description:
@ -2336,7 +2336,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
] ]
}, },
@ -2433,7 +2433,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
] ]
}, },
@ -2478,7 +2478,7 @@ module.exports = {
types: [ types: [
{ {
type: "boolean", type: "boolean",
multiple: true multiple: false
} }
], ],
description: "`true`: use polling." description: "`true`: use polling."

View File

@ -53,7 +53,9 @@ function addFlag(schemaPath, schemaPart, multiple) {
const duplicateIndex = flags[name].types.findIndex(() => type === type); const duplicateIndex = flags[name].types.findIndex(() => type === type);
if (duplicateIndex > -1) { if (duplicateIndex > -1) {
if (multiple) {
flags[name].types[duplicateIndex].multiple = true; flags[name].types[duplicateIndex].multiple = true;
}
break; break;
} }
@ -70,7 +72,7 @@ const specialSchemaPathNames = {
// TODO support `not` and `if/then/else` // TODO support `not` and `if/then/else`
// TODO support `const`, but we don't use it on our schema // TODO support `const`, but we don't use it on our schema
function traverse(schemaPart, schemaPath = "", depth = 0, inArray = false) { function traverse(schemaPart, schemaPath = "", inArray = false, depth = 0) {
if (ignoredSchemaPaths.has(schemaPath)) { if (ignoredSchemaPaths.has(schemaPath)) {
return; return;
} }
@ -103,8 +105,8 @@ function traverse(schemaPart, schemaPath = "", depth = 0, inArray = false) {
traverse( traverse(
schemaPart.properties[property], schemaPart.properties[property],
schemaPath ? `${schemaPath}/${property}` : property, schemaPath ? `${schemaPath}/${property}` : property,
depth + 1, inArray,
inArray depth + 1
) )
); );
} }
@ -115,13 +117,13 @@ function traverse(schemaPart, schemaPath = "", depth = 0, inArray = false) {
if (schemaPart.type === "array") { if (schemaPart.type === "array") {
if (Array.isArray(schemaPart.items)) { if (Array.isArray(schemaPart.items)) {
schemaPart.items.forEach(item => schemaPart.items.forEach(item =>
traverse(item, schemaPath, depth + 1, true) traverse(item, schemaPath, true, depth + 1)
); );
return; return;
} }
traverse(schemaPart.items, schemaPath, depth + 1, true); traverse(schemaPart.items, schemaPath, true, depth + 1);
return; return;
} }
@ -132,7 +134,7 @@ function traverse(schemaPart, schemaPath = "", depth = 0, inArray = false) {
const items = maybeOf; const items = maybeOf;
items.forEach((item, index) => items.forEach((item, index) =>
traverse(items[index], schemaPath, depth + 1, inArray) traverse(items[index], schemaPath, inArray, depth + 1)
); );
return; return;