Add asar-supported fs.access implementation

This commit is contained in:
Kevin Sawicki 2016-07-25 10:49:20 -07:00
parent a518c47f4c
commit 3ad5504194
2 changed files with 73 additions and 0 deletions

View file

@ -534,6 +534,32 @@ describe('asar package', function () {
})
})
describe('fs.access', function () {
it('throws an error when called with write mode', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
fs.access(p, fs.constants.R_OK | fs.constants.W_OK, function (err) {
assert.equal(err.code, 'EACCES')
done()
})
})
it('throws an error when called on non-existent file', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
fs.access(p, function (err) {
assert.equal(err.code, 'ENOENT')
done()
})
})
it('allows write mode for unpacked files', function (done) {
var p = path.join(fixtures, 'asar', 'unpack.asar', 'a.txt')
fs.access(p, fs.constants.R_OK | fs.constants.W_OK, function (err) {
assert(err == null)
done()
})
})
})
describe('child_process.fork', function () {
it('opens a normal js file', function (done) {
var child = ChildProcess.fork(path.join(fixtures, 'asar', 'a.asar', 'ping.js'))