MCPcopy Create free account
hub / github.com/SethGammon/Citadel / resolveCampaignPath

Function resolveCampaignPath

scripts/campaign.js:50–66  ·  view source on GitHub ↗
(projectRoot, target)

Source from the content-addressed store, hash-verified

48}
49
50function resolveCampaignPath(projectRoot, target) {
51 if (!target) throw new Error('Missing campaign slug or path.');
52
53 const direct = path.resolve(projectRoot, target);
54 if (fs.existsSync(direct) && fs.statSync(direct).isFile()) return direct;
55
56 const paths = getCampaignPaths(projectRoot);
57 const slug = target.endsWith('.md') ? target : `${target}.md`;
58 const candidates = [
59 path.join(paths.campaignsDir, slug),
60 path.join(paths.completedDir, slug),
61 ];
62
63 const match = candidates.find((candidate) => fs.existsSync(candidate));
64 if (!match) throw new Error(`Campaign not found: ${target}`);
65 return match;
66}
67
68function main() {
69 const args = parseArgs(process.argv.slice(2));

Callers 1

mainFunction · 0.70

Calls 1

getCampaignPathsFunction · 0.85

Tested by

no test coverage detected