Recognize asar archive with unpacked files
This commit is contained in:
parent
dc82553fc3
commit
b5a8cfb704
9 changed files with 84 additions and 55 deletions
|
@ -90,7 +90,7 @@ overrideAPI = (module, name, arg = 0) ->
|
|||
return callback new Error("Invalid package #{asarPath}") unless archive
|
||||
|
||||
newPath = archive.copyFileOut filePath
|
||||
return callback createNotFoundError(asarPath, filePath) unless newPath
|
||||
return callback createNotFoundError(asarPath, filePath) unless newPath
|
||||
|
||||
arguments[arg] = newPath
|
||||
old.apply this, arguments
|
||||
|
@ -218,6 +218,10 @@ exports.wrapFsWithAsar = (fs) ->
|
|||
info = archive.getFileInfo filePath
|
||||
return callback createNotFoundError(asarPath, filePath) unless info
|
||||
|
||||
if info.unpacked
|
||||
realPath = archive.copyFileOut filePath
|
||||
return fs.readFile realPath, options, callback
|
||||
|
||||
if not options
|
||||
options = encoding: null, flag: 'r'
|
||||
else if util.isString options
|
||||
|
@ -247,6 +251,10 @@ exports.wrapFsWithAsar = (fs) ->
|
|||
info = archive.getFileInfo filePath
|
||||
throw createNotFoundError(asarPath, filePath) unless info
|
||||
|
||||
if info.unpacked
|
||||
realPath = archive.copyFileOut filePath
|
||||
return fs.readFileSync realPath, options
|
||||
|
||||
if not options
|
||||
options = encoding: null, flag: 'r'
|
||||
else if util.isString options
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue