electron/lib/common/asar_init.js

21 lines
656 B
JavaScript
Raw Normal View History

2016-03-25 19:57:17 +00:00
;(function () {
return function (process, require, asarSource) {
2016-01-19 18:25:03 +00:00
// Make asar.coffee accessible via "require".
2016-03-25 19:57:17 +00:00
process.binding('natives').ATOM_SHELL_ASAR = asarSource
2016-01-12 02:40:23 +00:00
2016-01-19 18:25:03 +00:00
// Monkey-patch the fs module.
2016-03-25 19:57:17 +00:00
require('ATOM_SHELL_ASAR').wrapFsWithAsar(require('fs'))
2016-01-12 02:40:23 +00:00
2016-01-19 18:25:03 +00:00
// Make graceful-fs work with asar.
2016-03-25 19:57:17 +00:00
var source = process.binding('natives')
source['original-fs'] = source.fs
2016-03-27 10:13:15 +00:00
return source['fs'] = `
2016-03-25 19:57:17 +00:00
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`
}
})()