MCPcopy Create free account
hub / github.com/webpack/webpack-cli / #neededOptionNames

Method #neededOptionNames

packages/webpack-cli/src/webpack-cli.ts:958–1001  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

956 }
957
958 #neededOptionNames(): Set<string> | undefined {
959 const argv = this.#argvForParsing;
960
961 if (!argv) {
962 return undefined;
963 }
964
965 const names = new Set<string>();
966
967 for (const token of argv) {
968 // Must start with `-` to name an option.
969 if (token.length < 2 || token.charCodeAt(0) !== 45) {
970 continue;
971 }
972
973 if (token.charCodeAt(1) === 45) {
974 // Long option: `--name` or `--name=value`.
975 let name = token.slice(2);
976 const equalsIndex = name.indexOf("=");
977
978 if (equalsIndex !== -1) {
979 name = name.slice(0, equalsIndex);
980 }
981
982 if (!name) {
983 continue;
984 }
985
986 names.add(name);
987
988 // `--no-x` must register the `x` option (which provides the negation).
989 if (name.startsWith("no-")) {
990 names.add(name.slice(3));
991 }
992 } else {
993 // Register every letter of a short token to cover both attached values (`-d<value>`) and combined flags (`-abc`); over-registering is harmless.
994 for (const char of token.slice(1).split("=", 1)[0]) {
995 names.add(char);
996 }
997 }
998 }
999
1000 return names;
1001 }
1002
1003 #isOptionNeeded(option: CommandOption, neededOptions: Set<string>): boolean {
1004 if (neededOptions.has(option.name)) {

Callers 1

makeCommandMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected