mirror of
https://github.com/resend/react-email.git
synced 2026-09-14 14:18:02 +08:00
fb666720a7
Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
30 lines
877 B
TypeScript
30 lines
877 B
TypeScript
import { existsSync, promises as fs } from 'node:fs';
|
|
import path from 'node:path';
|
|
import url from 'node:url';
|
|
|
|
const filename = url.fileURLToPath(import.meta.url);
|
|
const dirname = path.dirname(filename);
|
|
|
|
const previewServerRoot = path.resolve(dirname, '..');
|
|
const emailsDirectoryPath = path.join(previewServerRoot, 'emails');
|
|
|
|
const seedPath = path.join(dirname, './utils/default-seed/');
|
|
|
|
if (existsSync(emailsDirectoryPath)) {
|
|
console.info(
|
|
'Deleting all files inside the emails directory (except for .gitkeep)',
|
|
);
|
|
const files = await fs.readdir(emailsDirectoryPath);
|
|
for await (const file of files) {
|
|
if (file === '.gitkeep') {
|
|
continue;
|
|
}
|
|
await fs.rm(file, { recursive: true, force: true });
|
|
}
|
|
}
|
|
|
|
console.info('Copying over the default seed to the emails directory');
|
|
await fs.cp(seedPath, emailsDirectoryPath, {
|
|
recursive: true,
|
|
});
|