Make process.dlopen work for asar packages.

This commit is contained in:
Cheng Zhao 2014-09-25 21:49:28 +08:00
parent 05317ad81e
commit 390b804ca0

View file

@ -220,3 +220,16 @@ fs.readdirSync = (p) ->
throw createNotFoundError(asarPath, filePath) unless files
files
dlopen = process.dlopen
require('module')._extensions['.node'] = process.dlopen = (module, p) ->
[isAsar, asarPath, filePath] = splitPath p
return dlopen.apply this, arguments unless isAsar
archive = getOrCreateArchive asarPath
throw new Error("Invalid package #{asarPath}") unless archive
newPath = archive.copyFileOut filePath
throw createNotFoundError(asarPath, filePath) unless newPath
dlopen module, newPath