Remove number and add int and float insted

This commit is contained in:
Fabian Stamm
2022-04-13 19:01:12 +00:00
parent 339d3006d6
commit b980af4b17
10 changed files with 64 additions and 41 deletions

View File

@ -1,5 +1,5 @@
import * as FS from "fs";
import * as FSE from "fs-extra"
import * as FSE from "fs-extra";
import * as Path from "path";
import {
EnumDefinition,
@ -11,7 +11,10 @@ import {
export abstract class CompileTarget<T = any> {
abstract name: string;
constructor(private outputFolder: string, protected options: T & { use_messagepack: boolean }) {
constructor(
private outputFolder: string,
protected options: T & { allow_bytes: boolean }
) {
if (!FS.existsSync(outputFolder)) {
FS.mkdirSync(outputFolder, {
recursive: true,
@ -30,12 +33,13 @@ export abstract class CompileTarget<T = any> {
abstract finalize(steps: Step[]): void;
protected writeFile(name: string, content: string | Promise<string>) {
let resPath = Path.join(this.outputFolder, name);
let resDir = Path.dirname(resPath);
if (!FS.existsSync(resDir)) FS.mkdirSync(resDir, { recursive: true });
if (content instanceof Promise) {
content.then((res) =>
FS.writeFileSync(Path.join(this.outputFolder, name), res)
);
content.then((res) => FS.writeFileSync(resPath, res));
} else {
FS.writeFileSync(Path.join(this.outputFolder, name), content);
FS.writeFileSync(resPath, content);
}
}
@ -59,12 +63,10 @@ export abstract class CompileTarget<T = any> {
return res.join("\n");
}
protected loadTemplateFolder(name:string) {
protected loadTemplateFolder(name: string) {
let root = Path.join(__dirname, "../templates/", name);
FSE.copySync(root, this.outputFolder, {
});
FSE.copySync(root, this.outputFolder, {});
}
}