electron/lib/common/asar_init.js
2016-03-30 17:00:33 -07:00

20 lines
649 B
JavaScript

;(function () {
return function (process, require, asarSource) {
// Make asar.coffee accessible via "require".
process.binding('natives').ATOM_SHELL_ASAR = asarSource
// Monkey-patch the fs module.
require('ATOM_SHELL_ASAR').wrapFsWithAsar(require('fs'))
// Make graceful-fs work with asar.
var source = process.binding('natives')
source['original-fs'] = source.fs
source['fs'] = `
var nativeModule = new process.NativeModule('original-fs')
nativeModule.cache()
nativeModule.compile()
var asar = require('ATOM_SHELL_ASAR')
asar.wrapFsWithAsar(nativeModule.exports)
module.exports = nativeModule.exports`
}
})()