🐛 Ensured directory exists before attempting write

- Currently, nothing happens if the file doesn't exist, the error is swallowed
- This module should ensure the directory exists at the point of write, else Ghost has to do too much
- TODO: improve the testing and error handling here as well
This commit is contained in:
Hannah Wolfe 2021-11-19 12:49:41 +00:00
parent 78559033cd
commit 0ffeee6712

View File

@ -101,6 +101,9 @@ class Minifier {
async writeFile(contents, dest) {
if (contents) {
let writePath = this.getFullDest(dest);
// Ensure the output folder exists
await fs.mkdir(this.destPath, {recursive: true});
// Create the file
await fs.writeFile(writePath, contents);
return writePath;
}