Skip to content

Commit

Permalink
fix: support async child process methods without callback in asar (im…
Browse files Browse the repository at this point in the history
…proved)
  • Loading branch information
alexgreenland committed Dec 4, 2018
1 parent 398fc6a commit c58517f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/common/asar.js
Expand Up @@ -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)
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit c58517f

Please sign in to comment.