(projectRoot, target)
| 48 | } |
| 49 | |
| 50 | function 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 | |
| 68 | function main() { |
| 69 | const args = parseArgs(process.argv.slice(2)); |
no test coverage detected