This commit is contained in:
David Nguyen
2025-05-07 15:03:20 +10:00
parent 419bc02171
commit 7abfc9e271
390 changed files with 21254 additions and 12607 deletions

View File

@ -1,28 +1,21 @@
import fs from 'node:fs';
import path from 'node:path';
const seedDatabase = async () => {
const files = fs.readdirSync(path.join(__dirname, './seed'));
for (const file of files) {
const stat = fs.statSync(path.join(__dirname, './seed', file));
if (stat.isFile()) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const mod = require(path.join(__dirname, './seed', file));
if ('seedDatabase' in mod && typeof mod.seedDatabase === 'function') {
console.log(`[SEEDING]: ${file}`);
try {
await mod.seedDatabase();
} catch (e) {
console.log(`[SEEDING]: Seed failed for ${file}`);
console.error(e);
}
}
}
}
// const files = fs.readdirSync(path.join(__dirname, './seed'));
// for (const file of files) {
// const stat = fs.statSync(path.join(__dirname, './seed', file));
// if (stat.isFile()) {
// // eslint-disable-next-line @typescript-eslint/no-var-requires
// const mod = require(path.join(__dirname, './seed', file));
// if ('seedDatabase' in mod && typeof mod.seedDatabase === 'function') {
// console.log(`[SEEDING]: ${file}`);
// try {
// await mod.seedDatabase();
// } catch (e) {
// console.log(`[SEEDING]: Seed failed for ${file}`);
// console.error(e);
// }
// }
// }
// }
};
seedDatabase()