MCPcopy
hub / github.com/webpack/webpack / processArguments

Function processArguments

lib/cli.js:782–828  ·  view source on GitHub ↗
(args, config, values)

Source from the content-addressed store, hash-verified

780 * @returns {Problem[] | null} problems or null for success
781 */
782const processArguments = (args, config, values) => {
783 /** @type {Problem[]} */
784 const problems = [];
785 for (const key of Object.keys(values)) {
786 const arg = args[key];
787 if (!arg) {
788 problems.push({
789 type: "unknown-argument",
790 path: "",
791 argument: key
792 });
793 continue;
794 }
795 /**
796 * Processes the provided value.
797 * @param {Value} value value
798 * @param {number | undefined} i index
799 */
800 const processValue = (value, i) => {
801 /** @type {Problem[]} */
802 const currentProblems = [];
803 for (const argConfig of arg.configs) {
804 const problem = processArgumentConfig(argConfig, config, value, i);
805 if (!problem) {
806 return;
807 }
808 currentProblems.push({
809 ...problem,
810 argument: key,
811 value,
812 index: i
813 });
814 }
815 problems.push(...currentProblems);
816 };
817 const value = values[key];
818 if (Array.isArray(value)) {
819 for (let i = 0; i < value.length; i++) {
820 processValue(value[i], i);
821 }
822 } else {
823 processValue(value, undefined);
824 }
825 }
826 if (problems.length === 0) return null;
827 return problems;
828};
829
830/**
831 * Checks whether this object is color supported.

Callers 2

testFunction · 0.85
Cli.basictest.jsFile · 0.85

Calls 4

processValueFunction · 0.85
isArrayMethod · 0.80
keysMethod · 0.65
pushMethod · 0.45

Tested by 1

testFunction · 0.68