Move templates

This commit is contained in:
Jake Howard 2023-04-20 21:08:59 +01:00
parent 8c49e0fbc2
commit 215a322c85
Signed by: jake
GPG Key ID: 57AFB45680EDD477
3 changed files with 9 additions and 7 deletions

View File

@ -5,16 +5,18 @@ import { paramCase } from 'change-case';
import { writeFile, readFile } from 'node:fs/promises';
import Handlebars from 'handlebars';
import { mkdirp } from 'mkdirp'
import { join } from 'path';
const LINGUIST_URL = "https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml";
const ROOT_DIR = process.cwd();
const DIST_DIR = join(ROOT_DIR, "dist")
function slugifyLanguage(language) {
return paramCase(language.replace("#", " Sharp").replace("++", " Plus Plus"));
}
async function main() {
await mkdirp("dist");
await mkdirp(DIST_DIR);
const response = await fetch(LINGUIST_URL);
const body = parse(await response.text());
@ -37,13 +39,13 @@ async function main() {
};
}
await writeFile("dist/out.json", JSON.stringify(colours));
await writeFile(join(DIST_DIR, "out.json"), JSON.stringify(colours));
const cssTemplate = Handlebars.compile((await readFile("scripts/templates/template.css")).toString());
await writeFile("dist/out.css", cssTemplate({data: Object.values(colours)}));
const cssTemplate = Handlebars.compile((await readFile(join(ROOT_DIR, "templates/template.css"))).toString());
await writeFile(join(DIST_DIR, "out.css"), cssTemplate({data: Object.values(colours)}));
const scssTemplate = Handlebars.compile((await readFile("scripts/templates/template.scss")).toString());
await writeFile("dist/out.scss", scssTemplate({data: Object.values(colours)}));
const scssTemplate = Handlebars.compile((await readFile(join(ROOT_DIR, "templates/template.scss"))).toString());
await writeFile(join(DIST_DIR, "out.scss"), scssTemplate({data: Object.values(colours)}));
}