Delete the out directory if it already exists when exporting #1371
bennyburrito
started this conversation in
Ideas
Replies: 1 comment 5 replies
-
What version of |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Goals
Background
When I have been creating emails, if I change the folder structure, I then have to remember to delete the out directory before exporting again otherwise the export creates duplicate files which then gets confusing. Simply deleting the export directory of choice if it already exists means it is only creating whatever is in the folders at the time and removes old templates. We use this system on our current setup and it is very useful.
Proposal
By adding this code below under the spinner, emailsDirectoryMetadata... variable at the top of the exportTemplates function variable in the node_modules/react-email/cli/index.js file, when someone runs the email export command, it will delete whatever directory they have chosen or the out as default if the folder already exists. I have tested it and it works as expected and means I can trust the emails in the folder and correct at the time of exporting.
// Delete the out directory if it exists
if (import_node_fs4.default.existsSync(pathToWhereEmailMarkupShouldBeDumped)) {
import_shelljs.rm('-rf', pathToWhereEmailMarkupShouldBeDumped);
}
Beta Was this translation helpful? Give feedback.
All reactions