MCPcopy Create free account
hub / github.com/Shazbot/WH3-Mod-Manager / executePackFilesDropdownNode

Function executePackFilesDropdownNode

src/nodeExecutor.ts:436–539  ·  view source on GitHub ↗
(
  nodeId: string,
  textValue: string,
  config?: unknown,
)

Source from the content-addressed store, hash-verified

434}
435
436async function executePackFilesDropdownNode(
437 nodeId: string,
438 textValue: string,
439 config?: unknown,
440): Promise<NodeExecutionResult> {
441 // Parse configuration (or use textValue directly for backwards compatibility)
442 const parsedConfig = getNodeConfig<{ selectedPack?: string }>(config, textValue);
443 const selectedPack = parsedConfig?.selectedPack ?? textValue;
444
445 console.log(`PackFiles Dropdown Node ${nodeId}: Processing selected pack "${selectedPack}"`);
446
447 const packFiles = [] as PackFilesNodeFile[];
448
449 if (!selectedPack || selectedPack.trim() === "") {
450 return {
451 success: false,
452 error: "No pack selected. Please select a pack from the dropdown.",
453 };
454 }
455
456 try {
457 // Check if selected pack is the base game pack
458 const baseGamePackName = gameToPackWithDBTablesName[appData.currentGame];
459 const isBaseGamePack = selectedPack === baseGamePackName;
460
461 if (isBaseGamePack) {
462 // Add base game pack directly
463 const baseGameFolder = appData.gamesToGameFolderPaths[appData.currentGame].dataFolder;
464 if (baseGameFolder) {
465 const baseGamePackPath = path.join(baseGameFolder, baseGamePackName);
466 if (fs.existsSync(baseGamePackPath)) {
467 packFiles.push({
468 name: baseGamePackName,
469 path: baseGamePackPath,
470 loaded: true,
471 });
472 console.log(`PackFiles Dropdown Node ${nodeId}: Added base game pack from ${baseGamePackPath}`);
473 } else {
474 console.warn(`PackFiles Dropdown Node ${nodeId}: Base game pack not found at ${baseGamePackPath}`);
475 return {
476 success: false,
477 error: `Base game pack not found at ${baseGamePackPath}`,
478 };
479 }
480 }
481 } else {
482 // Find the selected mod by name
483 let foundMod = appData.enabledMods.find((mod) => mod.name === selectedPack);
484 if (!foundMod) {
485 foundMod = appData.allMods.find((mod) => mod.name === selectedPack);
486 }
487
488 if (foundMod) {
489 packFiles.push({
490 name: path.basename(foundMod.path),
491 path: foundMod.path,
492 loaded: true,
493 });

Callers 1

executeNodeActionFunction · 0.85

Calls 1

getNodeConfigFunction · 0.85

Tested by

no test coverage detected