asar_init.js 639 B

1234567891011121314151617181920
  1. ;(function () {
  2. return function (process, require, asarSource) {
  3. // Make asar.js accessible via "require".
  4. process.binding('natives').ELECTRON_ASAR = asarSource
  5. // Monkey-patch the fs module.
  6. require('ELECTRON_ASAR').wrapFsWithAsar(require('fs'))
  7. // Make graceful-fs work with asar.
  8. var source = process.binding('natives')
  9. source['original-fs'] = source.fs
  10. source['fs'] = `
  11. var nativeModule = new process.NativeModule('original-fs')
  12. nativeModule.cache()
  13. nativeModule.compile()
  14. var asar = require('ELECTRON_ASAR')
  15. asar.wrapFsWithAsar(nativeModule.exports)
  16. module.exports = nativeModule.exports`
  17. }
  18. })()