Copy API directory to root for Vercel deployment
cgen-1d070bc977e248ca8344883e0dfb69eb
This commit is contained in:
parent
3f74b5cfde
commit
d98afbf0b9
1 changed files with 36 additions and 0 deletions
36
copy-api.js
Normal file
36
copy-api.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env node
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function copyDir(src, dest) {
|
||||
if (!fs.existsSync(src)) {
|
||||
console.warn(`Source directory not found: ${src}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fs.existsSync(dest)) {
|
||||
fs.rmSync(dest, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
fs.mkdirSync(dest, { recursive: true });
|
||||
|
||||
const entries = fs.readdirSync(src, { withFileTypes: true });
|
||||
|
||||
for (const entry of entries) {
|
||||
const srcPath = path.join(src, entry.name);
|
||||
const destPath = path.join(dest, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
copyDir(srcPath, destPath);
|
||||
} else {
|
||||
fs.copyFileSync(srcPath, destPath);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Copied ${src} to ${dest}`);
|
||||
}
|
||||
|
||||
const srcApi = path.resolve(__dirname, 'api');
|
||||
const destApi = path.resolve(__dirname, '..', 'api');
|
||||
|
||||
copyDir(srcApi, destApi);
|
||||
Loading…
Reference in a new issue