-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcore.ts
More file actions
32 lines (24 loc) · 978 Bytes
/
core.ts
File metadata and controls
32 lines (24 loc) · 978 Bytes
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 'dotenv/config';
import { readFile } from 'fs-extra';
import { marked } from 'marked';
import * as polyfills from './list';
import { generateHomePage, SavedPolyfill } from './view';
export async function savePolyfills(meta: typeof polyfills) {
const polyfill_list = Object.entries(meta),
saved_polyfills: SavedPolyfill[] = [];
for (const [name, Package] of polyfill_list)
try {
const polyfill = new Package();
await polyfill.save();
const { packageName, sourceMapURLs } = polyfill;
saved_polyfills.push({ name, packageName, sourceMapURLs });
} catch (error) {
console.error(error);
throw error;
}
return saved_polyfills;
}
export async function makeHomePage(saved_polyfills: SavedPolyfill[]) {
const homeBody = (await readFile('ReadMe.md')) + '';
return `<!DocType HTML>${generateHomePage(marked(homeBody) as string, saved_polyfills)}`;
}