Skip to content

Commit

Permalink
fix: preserve module _gen dir when coming from external repo (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Mar 9, 2024
1 parent e230b7f commit 095e281
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/project/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,24 @@ async function fetchAndResolveModule(
"external_modules",
moduleName,
);

// HACK: Copy _gen dir to temp dir to avoid overwriting it
const genPath = resolve(path, "_gen");
let tempGenDir: string | undefined;
if (await exists(genPath, { isDirectory: true })) {
tempGenDir = await Deno.makeTempDir();
await copy(genPath, tempGenDir, { overwrite: true });
}

// TODO: Only copy when needed, this copies every time the CLI is ran
await emptyDir(path);
await copy(sourcePath, path, { overwrite: true });

// HACK: Restore _gen dir
if (tempGenDir) {
await emptyDir(genPath);
await copy(tempGenDir, genPath, { overwrite: true });
}
} else {
// Use original path
path = sourcePath;
Expand Down

0 comments on commit 095e281

Please sign in to comment.