Skip to content

Commit

Permalink
fix: validate outDir absence in build json
Browse files Browse the repository at this point in the history
  • Loading branch information
rsaz committed Aug 4, 2024
1 parent 4abb6ab commit 1907684
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/commands/project.commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Compiler from "../utils/compiler";
*/
const tsconfigBuildPath = join(process.cwd(), "tsconfig.build.json");
const tsconfig = JSON.parse(readFileSync(tsconfigBuildPath, "utf-8"));
const outDir = tsconfig.compilerOptions.outDir || "dist";
const outDir = tsconfig.compilerOptions.outDir;

/**
* Load the configuration from the compiler
Expand Down Expand Up @@ -169,11 +169,26 @@ export const runCommand = async ({
);
break;
case "build":
if (!outDir) {
printError(
"Cannot build project. Please provide an outDir in tsconfig.build.json",
"build-command",
);
process.exit(1);
}
await cleanDist();
await compileTypescript();
await copyFiles();
break;
case "prod": {
if (!outDir) {
printError(
"Cannot run in prod mode. Please provide an outDir in tsconfig.build.json",
"prod-command",
);
process.exit(1);
}

let config: Array<string> = [];
if (opinionated) {
config = [
Expand Down

0 comments on commit 1907684

Please sign in to comment.