From 1cce5db26923e801bc1cf733b4432fb02224b00f Mon Sep 17 00:00:00 2001 From: RemixDev Date: Fri, 19 Aug 2022 18:18:26 +0200 Subject: [PATCH] Code cleanup --- deemix/downloader.js | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/deemix/downloader.js b/deemix/downloader.js index 8dcf969..cdf0f52 100644 --- a/deemix/downloader.js +++ b/deemix/downloader.js @@ -700,19 +700,14 @@ class Downloader { try { if (this.settings.executeCommand !== "") { const child = exec(this.settings.executeCommand.replaceAll("%folder%", shellEscape(this.downloadObject.extrasPath)).replaceAll("%filename%", shellEscape(track.filename)), - (error, stdout, stderr) => { - if (error) { - this.afterDownloadErrorReport("ExecuteCommand", error) - } - const itemData = { stderr, stdout }; - if (stderr) { - this.log(itemData, "stderr") - } - if (stdout) { - this.log(itemData, "stdout") - } - }) - + (error, stdout, stderr) => { + if (error) this.afterDownloadErrorReport("ExecuteCommand", error) + const itemData = { stderr, stdout } + if (stderr) this.log(itemData, "stderr") + if (stdout) this.log(itemData, "stdout") + } + ) + await new Promise((resolve) => { child.on('close', resolve) }) @@ -806,19 +801,14 @@ class Downloader { try{ if (this.settings.executeCommand !== "") { const child = exec(this.settings.executeCommand.replaceAll("%folder%", shellEscape(this.downloadObject.extrasPath)).replaceAll("%filename%", ''), - (error, stdout, stderr) => { - if (error) { - this.afterDownloadErrorReport("ExecuteCommand", error) - } - const itemData = { stderr, stdout }; - if (stderr) { - this.log(itemData, "stderr") - } - if (stdout) { - this.log(itemData, "stdout") - } - }) - + (error, stdout, stderr) => { + if (error) this.afterDownloadErrorReport("ExecuteCommand", error) + const itemData = { stderr, stdout } + if (stderr) this.log(itemData, "stderr") + if (stdout) this.log(itemData, "stdout") + } + ) + await new Promise((resolve) => { child.on('close', resolve) })