-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
32 lines (28 loc) · 807 Bytes
/
index.ts
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
30
31
32
import fs from "fs";
import path from "path";
import { getHeader } from "./header";
import { getFooter } from "./footer";
import { generateMarkup } from "./body";
/**
* Joins together content from templates
* @param map __global__ mutable color map
*/
export function generateHTML(map: ColorMap): string {
const scripts = fs.readFileSync(path.join(__dirname, "./scripts.js"), "utf-8");
return `
${getHeader(map)}
${generateMarkup(map)}
<script>
${scripts}
</script>
${getFooter()}
`;
}
/**
* @param html content for generated file
* @param outputDir where to save file
*/
export default function createFile(html: string, outputDir: string): void {
const outputPath = path.join(outputDir, "colorfast-report.html");
fs.writeFileSync(outputPath, html, "utf-8");
}