diff --git a/scripts/build.js b/scripts/build.js index 9fc2759..21b4ced 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -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)})); } diff --git a/scripts/templates/template.css b/templates/template.css similarity index 100% rename from scripts/templates/template.css rename to templates/template.css diff --git a/scripts/templates/template.scss b/templates/template.scss similarity index 100% rename from scripts/templates/template.scss rename to templates/template.scss