Skip to content

Commit

Permalink
clear the .mlogjs before putting the new files
Browse files Browse the repository at this point in the history
This change is meant to prevent scenarios where old files cause some
sort of conflict (like a .d.ts file that stopped existing
in the next version) causing its declarations to still be
present when they shouldn't
  • Loading branch information
JeanJPNM committed Dec 2, 2023
1 parent 0f94bf6 commit db3827f
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions compiler/src/bin/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { existsSync, readFileSync, writeFileSync, cpSync } from "node:fs";
import {
existsSync,
readFileSync,
writeFileSync,
cpSync,
rmSync,
} from "node:fs";
import { hideBin } from "yargs/helpers";
import { highlight } from "cli-highlight";
import yargs from "yargs";
Expand Down Expand Up @@ -106,13 +112,19 @@ yargs(hideBin(process.argv))
.parse();

export function setup(dir: string, tsconfig: boolean) {
const dotDir = join(dir, ".mlogjs");

if (existsSync(dotDir)) {
rmSync(dotDir, { recursive: true });
}

const libPath = getLibFolderPath();
cpSync(libPath, join(dir, ".mlogjs/lib"), {
cpSync(libPath, join(dotDir, "lib"), {
recursive: true,
});

const innerTSConfig = getInnerTSConfig();
writeFileSync(join(dir, ".mlogjs/tsconfig.json"), innerTSConfig);
writeFileSync(join(dotDir, "tsconfig.json"), innerTSConfig);

if (!tsconfig) return;
const rootTSConfig = getRootTSConfig();
Expand Down

0 comments on commit db3827f

Please sign in to comment.