1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Use promises for outputFormatter

This commit is contained in:
Evan Miller
2018-12-03 16:14:28 -05:00
parent 33d0a9d3b3
commit 0a7fd0288c

View File

@@ -44,13 +44,16 @@ function exportNote (nodeKey, storageKey, noteContent, targetPath, outputFormatt
if (outputFormatter) {
exportedData = outputFormatter(exportedData, exportTasks)
} else {
exportedData = Promise.resolve(exportedData)
}
const tasks = prepareTasks(exportTasks, storagePath, path.dirname(targetPath))
return Promise.all(tasks.map((task) => copyFile(task.src, task.dst)))
.then(() => {
return saveToFile(exportedData, targetPath)
.then(() => exportedData)
.then(data => {
return saveToFile(data, targetPath)
}).catch((err) => {
rollbackExport(tasks)
throw err