Move templates
This commit is contained in:
parent
8c49e0fbc2
commit
215a322c85
3 changed files with 9 additions and 7 deletions
|
@ -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)}));
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue