✨(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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user