Simplify build-api.js to transpile and filter utility files
cgen-fc45d34619f9477db10d6b7458668ae7
This commit is contained in:
parent
b59350cf94
commit
5526e13f82
1 changed files with 14 additions and 1 deletions
15
build-api.js
15
build-api.js
|
|
@ -10,6 +10,16 @@ console.log("Preparing API files for Vercel...");
|
|||
const srcApi = path.resolve(__dirname, "api");
|
||||
const destApi = path.resolve(__dirname, "..", "api");
|
||||
|
||||
const UTILITY_PATTERNS = [
|
||||
/^_/,
|
||||
/^opportunities\.ts$/,
|
||||
/^opportunities\.js$/,
|
||||
];
|
||||
|
||||
function isUtilityFile(filename) {
|
||||
return UTILITY_PATTERNS.some((pattern) => pattern.test(filename));
|
||||
}
|
||||
|
||||
function copyDir(src, dest) {
|
||||
if (fs.existsSync(dest)) {
|
||||
fs.rmSync(dest, { recursive: true, force: true });
|
||||
|
|
@ -24,7 +34,10 @@ function copyDir(src, dest) {
|
|||
if (entry.isDirectory()) {
|
||||
copyDir(srcPath, destPath);
|
||||
} else if (!entry.name.startsWith(".")) {
|
||||
fs.copyFileSync(srcPath, destPath);
|
||||
// Skip utility files at the root api level
|
||||
if (!isUtilityFile(entry.name) || src !== srcApi) {
|
||||
fs.copyFileSync(srcPath, destPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue