Make asar-require work under Node 2.3+
Since version 2.3 node has switched to the internal implementation of
"stat" [1], so the hooks no longer work. Fix that.
[1] b14fd1a720 (diff-d1234a869b3d648ebfcdce5a76747d71)
[2] https://bugs.gentoo.org/show_bug.cgi?id=584000
This commit is contained in:
Родитель
5c246a7055
Коммит
60cd8df02a
|
@ -1,6 +1,10 @@
|
||||||
asar = require 'asar'
|
asar = require 'asar'
|
||||||
fs = require 'fs'
|
fs = require 'fs'
|
||||||
path = require 'path'
|
path = require 'path'
|
||||||
|
try
|
||||||
|
node_module = require 'module'
|
||||||
|
catch error
|
||||||
|
node_module = null
|
||||||
|
|
||||||
# Separate asar package's path from full path.
|
# Separate asar package's path from full path.
|
||||||
splitPath = (p) ->
|
splitPath = (p) ->
|
||||||
|
@ -71,3 +75,11 @@ fs.realpathSync = (p) ->
|
||||||
stat = asar.statFile(asarPath, filePath)
|
stat = asar.statFile(asarPath, filePath)
|
||||||
filePath = stat.link if stat.link
|
filePath = stat.link if stat.link
|
||||||
path.join realpathSync(asarPath), filePath
|
path.join realpathSync(asarPath), filePath
|
||||||
|
|
||||||
|
if node_module and node_module._findPath
|
||||||
|
module_findPath = node_module._findPath
|
||||||
|
|
||||||
|
node_module._findPath = (request, paths, isMain) ->
|
||||||
|
[isAsar, asarPath, filePath] = splitPath request
|
||||||
|
return module_findPath.apply this, arguments unless isAsar
|
||||||
|
request
|
||||||
|
|
Загрузка…
Ссылка в новой задаче