-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender-tex-cli.ts
More file actions
29 lines (23 loc) · 1.01 KB
/
Copy pathrender-tex-cli.ts
File metadata and controls
29 lines (23 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// scripts/render-tex-cli.ts
// CLI entry point: reads a profile slug from argv, renders .tex to stdout.
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { renderTex } from "./render-tex.js";
import { validateCV, validateProfile } from "../data/validate.js";
import type { CV, ResumeProfile } from "../data/schema.js";
const slug = process.argv[2];
if (!slug) {
console.error("Usage: render-tex-cli.ts <slug>");
process.exit(1);
}
const repoRoot = resolve(import.meta.dirname, "..");
const cvPath = resolve(repoRoot, "data/cv.json");
const profilePath = resolve(repoRoot, `data/resumes/${slug}.json`);
const templatePath = resolve(repoRoot, "templates/resume.tex");
const cv = JSON.parse(readFileSync(cvPath, "utf-8"));
validateCV(cv);
const profile: ResumeProfile = JSON.parse(readFileSync(profilePath, "utf-8"));
validateProfile(profile);
const templateContent = readFileSync(templatePath, "utf-8");
const tex = renderTex(cv as CV, profile, templateContent);
process.stdout.write(tex);