(tokens) add TS generator and re-organize the repo

Add TS Generator which is a lot based on JS Generator.
This commit is contained in:
Nathan Vasse
2023-01-02 12:06:00 +01:00
committed by NathanVss
parent 2876d29025
commit 66e6aad84d
16 changed files with 159 additions and 35 deletions

View File

@@ -3,6 +3,7 @@ import * as fs from "fs";
import deepmerge from "deepmerge";
import { ConfigShape } from "TokensGenerator";
import { workPath } from "Paths";
import { register } from "ts-node";
import Config from "./Config";
const getLocalConfig = async () => {
@@ -14,11 +15,28 @@ const getLocalConfig = async () => {
console.log("No local config found, using default config.");
return {};
}
console.log("Found local config file: " + filename);
const ext = path.extname(filename);
if (ext === ".ts") {
registerTypescriptLoader();
}
const config = await import(filename);
return config.default;
};
const registerTypescriptLoader = () => {
register({
moduleTypes: {
"**/*.ts": "cjs",
},
compilerOptions: {
module: "commonjs",
},
});
};
const getDistConfig = async () => {
const config = await import("./cunningham.dist.js");
return config.default;