(bin) add tokens repo

This repo is made for the bin script that generates the tokens files,
at the moment it only generates a css file, but it is designed to be
able to generate any other file format ( Typescript, Javascript for example )
This commit is contained in:
Nathan Vasse
2022-12-01 12:03:37 +01:00
committed by NathanVss
parent 16172e7a00
commit 32a48e9e46
18 changed files with 440 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import path from "path";
import * as fs from "fs";
import deepmerge from "deepmerge";
import Config from "./Config";
import { ConfigShape } from "./TokensGenerator";
import { workPath } from "./Paths";
const getLocalConfig = async () => {
const filename = Config.configurationFilenames
.map((filename_) => path.join(workPath(), filename_))
.find((filename_) => fs.existsSync(filename_));
if (!filename) {
console.log("No local config found, using default config.");
return {};
}
const config = await import(filename);
return config.default;
};
const getDistConfig = async () => {
const config = await import("./cunningham.dist.js");
return config.default;
};
export const getConfig = async () => {
const localConfig = await getLocalConfig();
const distConfig = await getDistConfig();
const config: ConfigShape = deepmerge(distConfig, localConfig);
return config;
};