From 5eab3a123d789bf2bec9a2b52714330a49bdc2df Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Wed, 17 Mar 2021 19:14:36 -0400 Subject: [PATCH] Abiword: Use the async-provided callback to signal errors This avoids having two callbacks, which improves readability. --- src/node/utils/Abiword.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/node/utils/Abiword.js b/src/node/utils/Abiword.js index 348c76a0d..ca80967f2 100644 --- a/src/node/utils/Abiword.js +++ b/src/node/utils/Abiword.js @@ -77,17 +77,15 @@ if (os.type().indexOf('Windows') > -1) { }; spawnAbiword(); - doConvertTask = (task, callback) => { + const queue = async.queue((task, callback) => { abiword.stdin.write(`convert ${task.srcFile} ${task.destFile} ${task.type}\n`); stdoutCallback = (err) => { - callback(); if (err != null) console.error('Abiword File failed to convert', err); - task.callback(err); + callback(err); }; - }; + }, 1); - const queue = async.queue(doConvertTask, 1); exports.convertFile = (srcFile, destFile, type, callback) => { - queue.push({srcFile, destFile, type, callback}); + queue.push({srcFile, destFile, type}, callback); }; }