Merge pull request #2034 from hongrich/internalModuleReadFile-asar-unpack
Update internalModuleReadFile to support unpacked asar files
This commit is contained in:
commit
4f6e70a75c
2 changed files with 23 additions and 0 deletions
|
@ -323,6 +323,10 @@ exports.wrapFsWithAsar = (fs) ->
|
|||
return undefined unless info
|
||||
return '' if info.size is 0
|
||||
|
||||
if info.unpacked
|
||||
realPath = archive.copyFileOut filePath
|
||||
return fs.readFileSync realPath, encoding: 'utf8'
|
||||
|
||||
buffer = new Buffer(info.size)
|
||||
fd = archive.getFd()
|
||||
retrun undefined unless fd >= 0
|
||||
|
|
|
@ -45,6 +45,10 @@ describe 'asar package', ->
|
|||
assert /ENOENT/.test e
|
||||
async = true
|
||||
|
||||
it 'reads a normal file with unpacked files', ->
|
||||
p = path.join fixtures, 'asar', 'unpack.asar', 'a.txt'
|
||||
assert.equal fs.readFileSync(p).toString(), 'a\n'
|
||||
|
||||
describe 'fs.readFile', ->
|
||||
it 'reads a normal file', (done) ->
|
||||
p = path.join fixtures, 'asar', 'a.asar', 'file1'
|
||||
|
@ -372,6 +376,21 @@ describe 'asar package', ->
|
|||
done()
|
||||
child.send file
|
||||
|
||||
describe 'internalModuleReadFile', ->
|
||||
internalModuleReadFile = process.binding('fs').internalModuleReadFile
|
||||
|
||||
it 'read a normal file', ->
|
||||
file1 = path.join fixtures, 'asar', 'a.asar', 'file1'
|
||||
assert.equal internalModuleReadFile(file1).toString(), 'file1\n'
|
||||
file2 = path.join fixtures, 'asar', 'a.asar', 'file2'
|
||||
assert.equal internalModuleReadFile(file2).toString(), 'file2\n'
|
||||
file3 = path.join fixtures, 'asar', 'a.asar', 'file3'
|
||||
assert.equal internalModuleReadFile(file3).toString(), 'file3\n'
|
||||
|
||||
it 'reads a normal file with unpacked files', ->
|
||||
p = path.join fixtures, 'asar', 'unpack.asar', 'a.txt'
|
||||
assert.equal internalModuleReadFile(p).toString(), 'a\n'
|
||||
|
||||
describe 'asar protocol', ->
|
||||
url = require 'url'
|
||||
remote = require 'remote'
|
||||
|
|
Loading…
Reference in a new issue