MCPcopy
hub / github.com/webpack/webpack / schemaToArgumentConfig

Function schemaToArgumentConfig

lib/cli.js:177–210  ·  view source on GitHub ↗
(schemaPart)

Source from the content-addressed store, hash-verified

175 * @returns {Pick<ArgumentConfig, "type" | "values"> | undefined} partial argument config
176 */
177 const schemaToArgumentConfig = (schemaPart) => {
178 if (schemaPart.enum) {
179 return {
180 type: "enum",
181 values: schemaPart.enum
182 };
183 }
184 if (schemaPart.const !== undefined) {
185 return {
186 type: "enum",
187 values: [schemaPart.const]
188 };
189 }
190 switch (schemaPart.type) {
191 case "number":
192 return {
193 type: "number"
194 };
195 case "string":
196 return {
197 type: schemaPart.absolutePath ? "path" : "string"
198 };
199 case "boolean":
200 return {
201 type: "boolean"
202 };
203 }
204 if (schemaPart.instanceof === "RegExp") {
205 return {
206 type: "RegExp"
207 };
208 }
209 return undefined;
210 };
211
212 /**
213 * Adds the provided path to this object.

Callers 1

addFlagFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected