From c58517f6723f57816a9e86a45ef814c1279f0af7 Mon Sep 17 00:00:00 2001 From: Alex Greenland Date: Tue, 4 Dec 2018 13:34:38 +0000 Subject: [PATCH] fix: support async child process methods without callback in asar (improved) --- lib/common/asar.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/common/asar.js b/lib/common/asar.js index 3587f01497da1..08e20426e5644 100644 --- a/lib/common/asar.js +++ b/lib/common/asar.js @@ -143,10 +143,10 @@ return error } - const overrideAPISync = function (module, name, pathArgumentIndex) { + const overrideAPISync = function (module, name, pathArgumentIndex, fromAsync) { if (pathArgumentIndex == null) pathArgumentIndex = 0 const old = module[name] - module[name] = function () { + const func = function () { const pathArgument = arguments[pathArgumentIndex] const { isAsar, asarPath, filePath } = splitPath(pathArgument) if (!isAsar) return old.apply(this, arguments) @@ -160,6 +160,10 @@ arguments[pathArgumentIndex] = newPath return old.apply(this, arguments) } + if (fromAsync) { + return func + } + module[name] = func } const overrideAPI = function (module, name, pathArgumentIndex) { @@ -171,6 +175,9 @@ if (!isAsar) return old.apply(this, arguments) const callback = arguments[arguments.length - 1] + if (typeof callback !== 'function') { + return overrideAPISync(module, name, pathArgumentIndex, true).apply(this, arguments) + } const archive = getOrCreateArchive(asarPath) if (!archive) {