Skip to content

Commit

Permalink
Validate source directory existence.
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoryda committed Jan 15, 2025
1 parent 431e72a commit 8579e0e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion _api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import * as path from "path"
import * as url from "url"
import { existsSync } from "fs";
import { copyDirectory, deleteDirectory, getFilePathsInDirectory } from "./utils"
import { updateUrlsInDirectory, createUrlReplacer } from "./replaceUrls"
import { aggregateChainData } from "./aggregateChains"
Expand All @@ -24,7 +25,13 @@ const __dirname = path.dirname(__filename)
const rootDir = process.env.NETWORK_DIR || ""
const srcDir = path.resolve(__dirname, "../..", rootDir)
const distDir = path.resolve(__dirname, "../dist")

/**
* Validate source directory existence.
*/
if (!existsSync(srcDir)) {
console.error(`Source directory does not exist: ${srcDir}`);
process.exit(1);
}
deleteDirectory(distDir)
copyDirectory(srcDir, distDir, { excludes: ["testnets", "devnets", new RegExp("\\."), new RegExp("^_")] })

Expand Down

0 comments on commit 8579e0e

Please sign in to comment.