Closed musicq closed 1 year ago
Isn't it better to create the file's parent directories automatically when writing a file.
async function writeFile(fp, data) { await ensureDir(path.dirname(fp)) fs.writeFile(fp, data) }
So when we create the file, we no longer need to care about if the parent directory exists or not.
await writeFile('path/to/target/file.txt', 'data')
This is what .outputFile() does.
.outputFile()
Isn't it better to create the file's parent directories automatically when writing a file.
So when we create the file, we no longer need to care about if the parent directory exists or not.