2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const chai = require('chai')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								const dirtyChai = require('dirty-chai')
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-29 09:37:10 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const ChildProcess = require('child_process')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const fs = require('fs')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								const path = require('path')
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-04 01:36:20 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const temp = require('temp').track()
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const util = require('util')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const nativeImage = require('electron').nativeImage
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-03-18 12:37:06 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const features = process.electronBinding('features')
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-11 17:02:06 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const { expect } = chai
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								chai.use(dirtyChai)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								async function expectToThrowErrorWithCode (func, code) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  let error
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  try {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await func()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  } catch (e) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    error = e
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  expect(error).is.an('Error')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  expect(error).to.have.property('code').which.equals(code)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								describe('asar package', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const fixtures = path.join(__dirname, 'fixtures')
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const asarDir = path.join(fixtures, 'test.asar')
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-16 17:09:41 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  describe('node api', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:10:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    it('supports paths specified as a Buffer', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const file = Buffer.from(path.join(asarDir, 'a.asar', 'file1'))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(fs.existsSync(file)).to.be.true()
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:10:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.readFileSync', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('does not leak fd', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        let readCalls = 1
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-28 16:19:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        while (readCalls <= 10000) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-18 12:57:09 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.readFileSync(path.join(process.resourcesPath, 'default_app.asar', 'main.js'))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          readCalls++
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads a normal file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const file1 = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(fs.readFileSync(file1).toString().trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const file2 = path.join(asarDir, 'a.asar', 'file2')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(fs.readFileSync(file2).toString().trim()).to.equal('file2')
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const file3 = path.join(asarDir, 'a.asar', 'file3')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(fs.readFileSync(file3).toString().trim()).to.equal('file3')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads from a empty file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const file = path.join(asarDir, 'empty.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const buffer = fs.readFileSync(file)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(buffer).to.be.empty()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(buffer.toString()).to.equal('')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads a linked file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(fs.readFileSync(p).toString().trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads a file from linked directory', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p1 = path.join(asarDir, 'a.asar', 'link2', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(fs.readFileSync(p1).toString().trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p2 = path.join(asarDir, 'a.asar', 'link2', 'link2', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(fs.readFileSync(p2).toString().trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.readFileSync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }).to.throw(/ENOENT/)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('passes ENOENT error to callback when can not find file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        let async = false
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.readFile(p, function (error) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(async).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(error).to.match(/ENOENT/)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        async = true
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads a normal file with unpacked files', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'unpack.asar', 'a.txt')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(fs.readFileSync(p).toString().trim()).to.equal('a')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads a file in filesystem', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const p = path.resolve(asarDir, 'file')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(fs.readFileSync(p).toString().trim()).to.equal('file')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    describe('fs.readFile', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads a normal file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.readFile(p, function (err, content) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(String(content).trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads from a empty file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'empty.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.readFile(p, function (err, content) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(String(content)).to.equal('')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-31 09:32:45 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('reads from a empty file with encoding', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'empty.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-31 09:32:45 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.readFile(p, 'utf8', function (err, content) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(content).to.equal('')
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-31 09:32:45 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('reads a linked file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.readFile(p, function (err, content) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(String(content).trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads a file from linked directory', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link2', 'link2', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.readFile(p, function (err, content) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(String(content).trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.readFile(p, function (err) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err.code).to.equal('ENOENT')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.promises.readFile', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads a normal file', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const content = await fs.promises.readFile(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(String(content).trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads from a empty file', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'empty.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const content = await fs.promises.readFile(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(String(content)).to.equal('')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads from a empty file with encoding', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'empty.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const content = await fs.promises.readFile(p, 'utf8')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(content).to.equal('')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads a linked file', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const content = await fs.promises.readFile(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(String(content).trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads a file from linked directory', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link2', 'link2', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const content = await fs.promises.readFile(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(String(content).trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        await expectToThrowErrorWithCode(() => fs.promises.readFile(p), 'ENOENT')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-04 01:36:20 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.copyFile', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('copies a normal file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-04 01:36:20 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const dest = temp.path()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.copyFile(p, dest, function (err) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(fs.readFileSync(p).equals(fs.readFileSync(dest))).to.be.true()
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-04 01:36:20 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('copies a unpacked file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'unpack.asar', 'a.txt')
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-04 01:36:20 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const dest = temp.path()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.copyFile(p, dest, function (err) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(fs.readFileSync(p).equals(fs.readFileSync(dest))).to.be.true()
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-04 01:36:20 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.promises.copyFile', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('copies a normal file', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const dest = temp.path()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        await fs.promises.copyFile(p, dest)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(fs.readFileSync(p).equals(fs.readFileSync(dest))).to.be.true()
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('copies a unpacked file', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'unpack.asar', 'a.txt')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const dest = temp.path()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        await fs.promises.copyFile(p, dest)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(fs.readFileSync(p).equals(fs.readFileSync(dest))).to.be.true()
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-04 01:36:20 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.copyFileSync', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('copies a normal file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-04 01:36:20 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const dest = temp.path()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.copyFileSync(p, dest)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(fs.readFileSync(p).equals(fs.readFileSync(dest))).to.be.true()
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-04 01:36:20 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('copies a unpacked file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'unpack.asar', 'a.txt')
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-04 01:36:20 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const dest = temp.path()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.copyFileSync(p, dest)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(fs.readFileSync(p).equals(fs.readFileSync(dest))).to.be.true()
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-04 01:36:20 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.lstatSync', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('handles path with trailing slash correctly', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link2', 'link2', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.lstatSync(p)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.lstatSync(p + '/')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns information of root', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar')
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const stats = fs.lstatSync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isFile()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isDirectory()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isSymbolicLink()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.size).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-23 15:14:05 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns information of root with stats as bigint', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar')
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-23 15:14:05 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const stats = fs.lstatSync(p, { bigint: false })
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isFile()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isDirectory()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isSymbolicLink()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.size).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-23 15:14:05 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns information of a normal file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const ref2 = ['file1', 'file2', 'file3', path.join('dir1', 'file1'), path.join('link2', 'file1')]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for (let j = 0, len = ref2.length; j < len; j++) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          const file = ref2[j]
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          const p = path.join(asarDir, 'a.asar', file)
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          const stats = fs.lstatSync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isFile()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isDirectory()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isSymbolicLink()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.size).to.equal(6)
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-16 17:09:41 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns information of a normal directory', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const ref2 = ['dir1', 'dir2', 'dir3']
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for (let j = 0, len = ref2.length; j < len; j++) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          const file = ref2[j]
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          const p = path.join(asarDir, 'a.asar', file)
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          const stats = fs.lstatSync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isFile()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isDirectory()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isSymbolicLink()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.size).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-16 17:09:41 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns information of a linked file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const ref2 = ['link1', path.join('dir1', 'link1'), path.join('link2', 'link2')]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for (let j = 0, len = ref2.length; j < len; j++) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          const file = ref2[j]
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          const p = path.join(asarDir, 'a.asar', file)
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          const stats = fs.lstatSync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isFile()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isDirectory()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isSymbolicLink()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.size).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-16 17:09:41 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns information of a linked directory', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const ref2 = ['link2', path.join('dir1', 'link2'), path.join('link2', 'link2')]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for (let j = 0, len = ref2.length; j < len; j++) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          const file = ref2[j]
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          const p = path.join(asarDir, 'a.asar', file)
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          const stats = fs.lstatSync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isFile()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isDirectory()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isSymbolicLink()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.size).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-16 17:09:41 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const ref2 = ['file4', 'file5', path.join('dir1', 'file4')]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for (let j = 0, len = ref2.length; j < len; j++) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          const file = ref2[j]
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          const p = path.join(asarDir, 'a.asar', file)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            fs.lstatSync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          }).to.throw(/ENOENT/)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    describe('fs.lstat', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('handles path with trailing slash correctly', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link2', 'link2', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.lstat(p + '/', done)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns information of root', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.lstat(p, function (err, stats) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isFile()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isDirectory()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isSymbolicLink()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.size).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-23 15:14:05 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns information of root with stats as bigint', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar')
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-23 15:14:05 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.lstat(p, { bigint: false }, function (err, stats) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isFile()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isDirectory()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isSymbolicLink()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.size).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-23 15:14:05 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns information of a normal file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link2', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.lstat(p, function (err, stats) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isFile()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isDirectory()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isSymbolicLink()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.size).to.equal(6)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns information of a normal directory', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'dir1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.lstat(p, function (err, stats) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isFile()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isDirectory()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isSymbolicLink()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.size).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns information of a linked file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link2', 'link1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.lstat(p, function (err, stats) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isFile()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isDirectory()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isSymbolicLink()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.size).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns information of a linked directory', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link2', 'link2')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.lstat(p, function (err, stats) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isFile()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isDirectory()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isSymbolicLink()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.size).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file4')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.lstat(p, function (err) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err.code).to.equal('ENOENT')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.promises.lstat', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('handles path with trailing slash correctly', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link2', 'link2', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        await fs.promises.lstat(p + '/')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns information of root', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const stats = await fs.promises.lstat(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isFile()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isDirectory()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isSymbolicLink()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.size).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns information of root with stats as bigint', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const stats = await fs.promises.lstat(p, { bigint: false })
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isFile()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isDirectory()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isSymbolicLink()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.size).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns information of a normal file', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link2', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const stats = await fs.promises.lstat(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isFile()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isDirectory()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isSymbolicLink()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.size).to.equal(6)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns information of a normal directory', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'dir1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const stats = await fs.promises.lstat(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isFile()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isDirectory()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isSymbolicLink()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.size).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns information of a linked file', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link2', 'link1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const stats = await fs.promises.lstat(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isFile()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isDirectory()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isSymbolicLink()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.size).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns information of a linked directory', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link2', 'link2')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const stats = await fs.promises.lstat(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isFile()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isDirectory()).to.be.false()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.isSymbolicLink()).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(stats.size).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file4')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        await expectToThrowErrorWithCode(() => fs.promises.lstat(p), 'ENOENT')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.realpathSync', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path root', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = 'a.asar'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = fs.realpathSync(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a normal file', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'file1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = fs.realpathSync(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a normal directory', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'dir1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = fs.realpathSync(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a linked file', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'link2', 'link1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = fs.realpathSync(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, 'a.asar', 'file1'))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a linked directory', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'link2', 'link2')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = fs.realpathSync(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, 'a.asar', 'dir1'))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of an unpacked file', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('unpack.asar', 'a.txt')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = fs.realpathSync(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          fs.realpathSync(path.join(parent, p))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }).to.throw(/ENOENT/)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.realpathSync.native', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path root', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync.native(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = 'a.asar'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = fs.realpathSync.native(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a normal file', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync.native(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'file1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = fs.realpathSync.native(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a normal directory', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync.native(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'dir1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = fs.realpathSync.native(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a linked file', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync.native(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'link2', 'link1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = fs.realpathSync.native(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, 'a.asar', 'file1'))
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a linked directory', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync.native(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'link2', 'link2')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = fs.realpathSync.native(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, 'a.asar', 'dir1'))
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of an unpacked file', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync.native(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('unpack.asar', 'a.txt')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = fs.realpathSync.native(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync.native(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          fs.realpathSync.native(path.join(parent, p))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }).to.throw(/ENOENT/)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    describe('fs.realpath', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path root', done => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = 'a.asar'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.realpath(path.join(parent, p), (err, r) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a normal file', done => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'file1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.realpath(path.join(parent, p), (err, r) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a normal directory', done => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'dir1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.realpath(path.join(parent, p), (err, r) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a linked file', done => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'link2', 'link1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.realpath(path.join(parent, p), (err, r) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(r).to.equal(path.join(parent, 'a.asar', 'file1'))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a linked directory', done => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'link2', 'link2')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.realpath(path.join(parent, p), (err, r) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(r).to.equal(path.join(parent, 'a.asar', 'dir1'))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of an unpacked file', done => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('unpack.asar', 'a.txt')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.realpath(path.join(parent, p), (err, r) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', done => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'not-exist')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.realpath(path.join(parent, p), err => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err.code).to.equal('ENOENT')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.promises.realpath', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path root', async () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = 'a.asar'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = await fs.promises.realpath(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a normal file', async () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'file1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = await fs.promises.realpath(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a normal directory', async () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'dir1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = await fs.promises.realpath(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a linked file', async () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'link2', 'link1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = await fs.promises.realpath(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, 'a.asar', 'file1'))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a linked directory', async () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'link2', 'link2')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = await fs.promises.realpath(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, 'a.asar', 'dir1'))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of an unpacked file', async () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('unpack.asar', 'a.txt')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const r = await fs.promises.realpath(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', async () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'not-exist')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        await expectToThrowErrorWithCode(() => fs.promises.realpath(path.join(parent, p)), 'ENOENT')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.realpath.native', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path root', done => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync.native(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = 'a.asar'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.realpath.native(path.join(parent, p), (err, r) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a normal file', done => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync.native(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'file1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.realpath.native(path.join(parent, p), (err, r) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a normal directory', done => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync.native(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'dir1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.realpath.native(path.join(parent, p), (err, r) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a linked file', done => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync.native(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'link2', 'link1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.realpath.native(path.join(parent, p), (err, r) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(r).to.equal(path.join(parent, 'a.asar', 'file1'))
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of a linked directory', done => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync.native(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'link2', 'link2')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.realpath.native(path.join(parent, p), (err, r) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(r).to.equal(path.join(parent, 'a.asar', 'dir1'))
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('returns real path of an unpacked file', done => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync.native(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('unpack.asar', 'a.txt')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.realpath.native(path.join(parent, p), (err, r) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(r).to.equal(path.join(parent, p))
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', done => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const parent = fs.realpathSync.native(asarDir)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join('a.asar', 'not-exist')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.realpath.native(path.join(parent, p), err => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err.code).to.equal('ENOENT')
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-12 00:10:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.readdirSync', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads dirs from root', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar')
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const dirs = fs.readdirSync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(dirs).to.deep.equal(['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2', 'ping.js'])
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads dirs from a normal dir', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'dir1')
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const dirs = fs.readdirSync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(dirs).to.deep.equal(['file1', 'file2', 'file3', 'link1', 'link2'])
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads dirs from a linked dir', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link2', 'link2')
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const dirs = fs.readdirSync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(dirs).to.deep.equal(['file1', 'file2', 'file3', 'link1', 'link2'])
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.readdirSync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }).to.throw(/ENOENT/)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    describe('fs.readdir', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads dirs from root', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.readdir(p, function (err, dirs) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(dirs).to.deep.equal(['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2', 'ping.js'])
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads dirs from a normal dir', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'dir1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.readdir(p, function (err, dirs) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(dirs).to.deep.equal(['file1', 'file2', 'file3', 'link1', 'link2'])
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads dirs from a linked dir', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link2', 'link2')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.readdir(p, function (err, dirs) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(dirs).to.deep.equal(['file1', 'file2', 'file3', 'link1', 'link2'])
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.readdir(p, function (err) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err.code).to.equal('ENOENT')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.promises.readdir', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads dirs from root', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const dirs = await fs.promises.readdir(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(dirs).to.deep.equal(['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2', 'ping.js'])
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads dirs from a normal dir', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'dir1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const dirs = await fs.promises.readdir(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(dirs).to.deep.equal(['file1', 'file2', 'file3', 'link1', 'link2'])
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads dirs from a linked dir', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'link2', 'link2')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const dirs = await fs.promises.readdir(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(dirs).to.deep.equal(['file1', 'file2', 'file3', 'link1', 'link2'])
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        await expectToThrowErrorWithCode(() => fs.promises.readdir(p), 'ENOENT')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.openSync', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('opens a normal/linked/under-linked-directory file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const ref2 = ['file1', 'link1', path.join('link2', 'file1')]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for (let j = 0, len = ref2.length; j < len; j++) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          const file = ref2[j]
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          const p = path.join(asarDir, 'a.asar', file)
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          const fd = fs.openSync(p, 'r')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          const buffer = Buffer.alloc(6)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.readSync(fd, buffer, 0, 6, 0)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(String(buffer).trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.closeSync(fd)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.openSync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }).to.throw(/ENOENT/)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    describe('fs.open', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('opens a normal file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.open(p, 'r', function (err, fd) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          const buffer = Buffer.alloc(6)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.read(fd, buffer, 0, 6, 0, function (err) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            expect(err).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            expect(String(buffer).trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            fs.close(fd, done)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.open(p, 'r', function (err) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err.code).to.equal('ENOENT')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.promises.open', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('opens a normal file', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const fh = await fs.promises.open(p, 'r')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const buffer = Buffer.alloc(6)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        await fh.read(buffer, 0, 6, 0)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(String(buffer).trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        await fh.close()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws ENOENT error when can not find file', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        await expectToThrowErrorWithCode(() => fs.promises.open(p, 'r'), 'ENOENT')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.mkdir', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws error when calling inside asar archive', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.mkdir(p, function (err) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err.code).to.equal('ENOTDIR')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.promises.mkdir', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws error when calling inside asar archive', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        await expectToThrowErrorWithCode(() => fs.promises.mkdir(p), 'ENOTDIR')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.mkdirSync', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws error when calling inside asar archive', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.mkdirSync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }).to.throw(/ENOTDIR/)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.exists', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('handles an existing file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        // eslint-disable-next-line
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.exists(p, function (exists) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(exists).to.be.true()
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('handles a non-existent file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        // eslint-disable-next-line
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fs.exists(p, function (exists) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(exists).to.be.false()
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('promisified version handles an existing file', (done) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        // eslint-disable-next-line
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        util.promisify(fs.exists)(p).then(exists => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(exists).to.be.true()
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('promisified version handles a non-existent file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        // eslint-disable-next-line
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        util.promisify(fs.exists)(p).then(exists => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(exists).to.be.false()
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    describe('fs.existsSync', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('handles an existing file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(fs.existsSync(p)).to.be.true()
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('handles a non-existent file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(fs.existsSync(p)).to.be.false()
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 10:49:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.access', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:17:40 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('accesses a normal file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:17:40 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.access(p, function (err) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.undefined()
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:17:40 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 10:49:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('throws an error when called with write mode', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 10:49:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.access(p, fs.constants.R_OK | fs.constants.W_OK, function (err) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err.code).to.equal('EACCES')
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 10:49:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws an error when called on non-existent file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 10:49:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.access(p, function (err) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err.code).to.equal('ENOENT')
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 10:49:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('allows write mode for unpacked files', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'unpack.asar', 'a.txt')
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 10:49:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.access(p, fs.constants.R_OK | fs.constants.W_OK, function (err) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err).to.be.null()
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 10:49:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.promises.access', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('accesses a normal file', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        await fs.promises.access(p)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws an error when called with write mode', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        await expectToThrowErrorWithCode(() => fs.promises.access(p, fs.constants.R_OK | fs.constants.W_OK), 'EACCES')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws an error when called on non-existent file', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        await expectToThrowErrorWithCode(() => fs.promises.access(p), 'ENOENT')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('allows write mode for unpacked files', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'unpack.asar', 'a.txt')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        await fs.promises.access(p, fs.constants.R_OK | fs.constants.W_OK)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:05:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('fs.accessSync', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:17:40 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('accesses a normal file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:17:40 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.accessSync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }).to.not.throw()
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:17:40 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:05:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('throws an error when called with write mode', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:05:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.accessSync(p, fs.constants.R_OK | fs.constants.W_OK)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }).to.throw(/EACCES/)
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:05:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('throws an error when called on non-existent file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:05:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.accessSync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }).to.throw(/ENOENT/)
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:05:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('allows write mode for unpacked files', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'unpack.asar', 'a.txt')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:05:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.accessSync(p, fs.constants.R_OK | fs.constants.W_OK)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }).to.not.throw()
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-25 11:05:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('child_process.fork', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-11 17:02:06 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      before(function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if (!features.isRunAsNodeEnabled()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          this.skip()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('opens a normal js file', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const child = ChildProcess.fork(path.join(asarDir, 'a.asar', 'ping.js'))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        child.on('message', function (msg) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(msg).to.equal('message')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        child.send('message')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('supports asar in the forked js', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const file = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const child = ChildProcess.fork(path.join(fixtures, 'module', 'asar.js'))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        child.on('message', function (content) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(content).to.equal(fs.readFileSync(file).toString())
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        child.send(file)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-19 11:08:08 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('child_process.exec', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const echo = path.join(asarDir, 'echo.asar', 'echo')
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-19 11:08:08 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('should not try to extract the command if there is a reference to a file inside an .asar', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-29 09:37:10 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        ChildProcess.exec('echo ' + echo + ' foo bar', function (error, stdout) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(error).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stdout.toString().replace(/\r/g, '')).to.equal(echo + ' foo bar\n')
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-19 11:08:08 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('can be promisified', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return util.promisify(ChildProcess.exec)('echo ' + echo + ' foo bar').then(({ stdout }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(stdout.toString().replace(/\r/g, '')).to.equal(echo + ' foo bar\n')
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-19 11:08:08 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    describe('child_process.execSync', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const echo = path.join(asarDir, 'echo.asar', 'echo')
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-19 11:08:08 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('should not try to extract the command if there is a reference to a file inside an .asar', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const stdout = ChildProcess.execSync('echo ' + echo + ' foo bar')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(stdout.toString().replace(/\r/g, '')).to.equal(echo + ' foo bar\n')
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-19 11:08:08 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('child_process.execFile', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const execFile = ChildProcess.execFile
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const execFileSync = ChildProcess.execFileSync
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const echo = path.join(asarDir, 'echo.asar', 'echo')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-11-16 00:05:46 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      before(function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if (process.platform !== 'darwin') {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          this.skip()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('executes binaries', function (done) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        execFile(echo, ['test'], function (error, stdout) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(error).to.be.null()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stdout).to.equal('test\n')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-12-18 07:27:39 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('executes binaries without callback', function (done) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const process = execFile(echo, ['test'])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        process.on('close', function (code) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(code).to.equal(0)
							 | 
						
					
						
							
								
									
										
										
										
											2018-12-18 07:27:39 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        process.on('error', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect.fail()
							 | 
						
					
						
							
								
									
										
										
										
											2018-12-18 07:27:39 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-30 12:45:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('execFileSync executes binaries', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const output = execFileSync(echo, ['test'])
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(String(output)).to.equal('test\n')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('can be promisified', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return util.promisify(ChildProcess.execFile)(echo, ['test']).then(({ stdout }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(stdout).to.equal('test\n')
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-19 09:38:42 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('internalModuleReadJSON', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const internalModuleReadJSON = process.binding('fs').internalModuleReadJSON
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('read a normal file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const file1 = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(internalModuleReadJSON(file1).toString().trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const file2 = path.join(asarDir, 'a.asar', 'file2')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(internalModuleReadJSON(file2).toString().trim()).to.equal('file2')
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const file3 = path.join(asarDir, 'a.asar', 'file3')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(internalModuleReadJSON(file3).toString().trim()).to.equal('file3')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('reads a normal file with unpacked files', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const p = path.join(asarDir, 'unpack.asar', 'a.txt')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(internalModuleReadJSON(p).toString().trim()).to.equal('a')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('util.promisify', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('can promisify all fs functions', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const originalFs = require('original-fs')
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-14 02:10:51 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const { hasOwnProperty } = Object.prototype
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-07 17:13:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        for (const [propertyName, originalValue] of Object.entries(originalFs)) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-10 11:35:37 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          // Some properties exist but have a value of `undefined` on some platforms.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          // E.g. `fs.lchmod`, which in only available on MacOS, see
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          // https://nodejs.org/docs/latest-v10.x/api/fs.html#fs_fs_lchmod_path_mode_callback
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          // Also check for `null`s, `hasOwnProperty()` can't handle them.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          if (typeof originalValue === 'undefined' || originalValue === null) continue
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-07 17:13:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          if (hasOwnProperty.call(originalValue, util.promisify.custom)) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            expect(fs).to.have.own.property(propertyName)
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-14 02:10:51 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								              .that.has.own.property(util.promisify.custom)
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-01 05:06:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    describe('process.noAsar', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const errorName = process.platform === 'win32' ? 'ENOENT' : 'ENOTDIR'
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      beforeEach(function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        process.noAsar = true
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      afterEach(function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        process.noAsar = false
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('disables asar support in sync API', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const file = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const dir = path.join(asarDir, 'a.asar', 'dir1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.readFileSync(file)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }).to.throw(new RegExp(errorName))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.lstatSync(file)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }).to.throw(new RegExp(errorName))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.realpathSync(file)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }).to.throw(new RegExp(errorName))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.readdirSync(dir)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }).to.throw(new RegExp(errorName))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('disables asar support in async API', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const file = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const dir = path.join(asarDir, 'a.asar', 'dir1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        fs.readFile(file, function (error) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(error.code).to.equal(errorName)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.lstat(file, function (error) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            expect(error.code).to.equal(errorName)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            fs.realpath(file, function (error) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								              expect(error.code).to.equal(errorName)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								              fs.readdir(dir, function (error) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                expect(error.code).to.equal(errorName)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('disables asar support in promises API', async function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const file = path.join(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const dir = path.join(asarDir, 'a.asar', 'dir1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        await expect(fs.promises.readFile(file)).to.be.eventually.rejectedWith(Error, new RegExp(errorName))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        await expect(fs.promises.lstat(file)).to.be.eventually.rejectedWith(Error, new RegExp(errorName))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        await expect(fs.promises.realpath(file)).to.be.eventually.rejectedWith(Error, new RegExp(errorName))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        await expect(fs.promises.readdir(dir)).to.be.eventually.rejectedWith(Error, new RegExp(errorName))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('treats *.asar as normal file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const originalFs = require('original-fs')
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const asar = path.join(asarDir, 'a.asar')
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const content1 = fs.readFileSync(asar)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const content2 = originalFs.readFileSync(asar)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(content1.compare(content2)).to.equal(0)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          fs.readdirSync(asar)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }).to.throw(/ENOTDIR/)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							
								
									
										
										
										
											2016-09-06 13:32:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('is reset to its original value when execSync throws an error', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        process.noAsar = false
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-09-06 13:32:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          ChildProcess.execSync(path.join(__dirname, 'does-not-exist.txt'))
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }).to.throw()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        expect(process.noAsar).to.be.false()
							 | 
						
					
						
							
								
									
										
										
										
											2016-09-06 13:32:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							
								
									
										
										
										
											2016-10-07 10:59:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    describe('process.env.ELECTRON_NO_ASAR', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-11 17:02:06 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      before(function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if (!features.isRunAsNodeEnabled()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          this.skip()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-10-07 10:59:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      it('disables asar support in forked processes', function (done) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const forked = ChildProcess.fork(path.join(__dirname, 'fixtures', 'module', 'no-asar.js'), [], {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          env: {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            ELECTRON_NO_ASAR: true
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        forked.on('message', function (stats) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isFile).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.size).to.equal(778)
							 | 
						
					
						
							
								
									
										
										
										
											2016-10-07 10:59:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      it('disables asar support in spawned processes', function (done) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const spawned = ChildProcess.spawn(process.execPath, [path.join(__dirname, 'fixtures', 'module', 'no-asar.js')], {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          env: {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            ELECTRON_NO_ASAR: true,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            ELECTRON_RUN_AS_NODE: true
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        let output = ''
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        spawned.stdout.on('data', function (data) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          output += data
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        spawned.stdout.on('close', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2016-10-07 10:59:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          const stats = JSON.parse(output)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(stats.isFile).to.be.true()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          expect(stats.size).to.equal(778)
							 | 
						
					
						
							
								
									
										
										
										
											2016-10-07 10:59:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  describe('asar protocol', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('can request a file in package', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const p = path.resolve(asarDir, 'a.asar', 'file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      $.get('file://' + p, function (data) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(data.trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('can request a file in package with unpacked files', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const p = path.resolve(asarDir, 'unpack.asar', 'a.txt')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      $.get('file://' + p, function (data) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(data.trim()).to.equal('a')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('can request a linked file in package', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const p = path.resolve(asarDir, 'a.asar', 'link2', 'link1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      $.get('file://' + p, function (data) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(data.trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('can request a file in filesystem', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const p = path.resolve(asarDir, 'file')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      $.get('file://' + p, function (data) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(data.trim()).to.equal('file')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('gets 404 when file is not found', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const p = path.resolve(asarDir, 'a.asar', 'no-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-16 17:39:11 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      $.ajax({
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        url: 'file://' + p,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        error: function (err) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          expect(err.status).to.equal(404)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          done()
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  describe('original-fs module', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const originalFs = require('original-fs')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('treats .asar as file', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const file = path.join(asarDir, 'a.asar')
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const stats = originalFs.statSync(file)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(stats.isFile()).to.be.true()
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('is available in forked scripts', function (done) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-11 17:02:06 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      if (!features.isRunAsNodeEnabled()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        this.skip()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const child = ChildProcess.fork(path.join(fixtures, 'module', 'original-fs.js'))
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      child.on('message', function (msg) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expect(msg).to.equal('object')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        done()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      child.send('message')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-26 18:55:12 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('can be used with streams', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      originalFs.createReadStream(path.join(asarDir, 'a.asar'))
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-26 18:55:12 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-02 14:06:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('has the same APIs as fs', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      expect(Object.keys(require('fs'))).to.deep.equal(Object.keys(require('original-fs')))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      expect(Object.keys(require('fs').promises)).to.deep.equal(Object.keys(require('original-fs').promises))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  describe('graceful-fs module', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const gfs = require('graceful-fs')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('recognize asar archvies', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const p = path.join(asarDir, 'a.asar', 'link1')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(gfs.readFileSync(p).toString().trim()).to.equal('file1')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('does not touch global fs object', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(fs.readdir).to.not.equal(gfs.readdir)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  describe('mkdirp module', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const mkdirp = require('mkdirp')
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('throws error when calling inside asar archive', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const p = path.join(asarDir, 'a.asar', 'not-exist')
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        mkdirp.sync(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      }).to.throw(/ENOTDIR/)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  describe('native-image', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('reads image from asar archive', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const p = path.join(asarDir, 'logo.asar', 'logo.png')
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const logo = nativeImage.createFromPath(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(logo.getSize()).to.deep.equal({
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        width: 55,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        height: 55
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-16 17:09:41 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    it('reads image from asar archive with unpacked files', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-02 06:33:07 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const p = path.join(asarDir, 'unpack.asar', 'atom.png')
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 01:17:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const logo = nativeImage.createFromPath(p)
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-20 19:04:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(logo.getSize()).to.deep.equal({
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        width: 1024,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        height: 1024
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								})
							 |