Newer
Older
ServerGenerator / src / CopyCodeFile.ts
@peter peter on 13 Sep 2020 489 bytes Extracted general code into util.ts.
import * as fs from "fs";
import { join } from "path";

const codeFileName = join(__dirname, "..", "src", "ExampleOutput", "util.ts");
let code = fs.readFileSync(codeFileName).toString();
code = code.replace(/`/g, "\\`").replace("$", "\\$");
const utilGenerator = `export const UtilCode = \`${code}\`;\n`;
const outputFileName = join(__dirname, "..", "src", "UtilGenerator.ts");
fs.writeFileSync(outputFileName, utilGenerator);
console.log(`Generated UtilGenerator at ${outputFileName}`);