electron/lib/common/asar_init.js

21 lines
639 B
JavaScript
Raw Normal View History

2016-03-25 12:57:17 -07:00
;(function () {
return function (process, require, asarSource) {
2016-05-23 10:28:32 -07:00
// Make asar.js accessible via "require".
process.binding('natives').ELECTRON_ASAR = asarSource
2016-01-11 18:40:23 -08:00
2016-01-19 10:25:03 -08:00
// Monkey-patch the fs module.
require('ELECTRON_ASAR').wrapFsWithAsar(require('fs'))
2016-01-11 18:40:23 -08:00
2016-01-19 10:25:03 -08:00
// Make graceful-fs work with asar.
2016-03-25 12:57:17 -07:00
var source = process.binding('natives')
source['original-fs'] = source.fs
2016-03-29 10:33:17 -07:00
source['fs'] = `
2016-03-25 12:57:17 -07:00
var nativeModule = new process.NativeModule('original-fs')
nativeModule.cache()
nativeModule.compile()
var asar = require('ELECTRON_ASAR')
2016-03-25 12:57:17 -07:00
asar.wrapFsWithAsar(nativeModule.exports)
module.exports = nativeModule.exports`
}
})()