electron/lib/common/asar_init.js

21 lines
877 B
JavaScript
Raw Normal View History

'use strict'
;(function () { // eslint-disable-line
return function (source, require, asarSource) {
// Expose fs module without asar support.
// NB: Node's 'fs' and 'internal/fs/streams' have a lazy-loaded circular
// dependency. So to expose the unmodified Node 'fs' functionality here,
// we have to copy both 'fs' *and* 'internal/fs/streams' and modify the
// copies to depend on each other instead of on our asarified 'fs' code.
source['original-fs'] = source.fs.replace("require('internal/fs/streams')", "require('original-fs/streams')")
source['original-fs/streams'] = source['internal/fs/streams'].replace("require('fs')", "require('original-fs')")
2016-05-23 17:28:32 +00:00
// Make asar.js accessible via "require".
source.ELECTRON_ASAR = asarSource
2016-01-12 02:40:23 +00:00
2016-01-19 18:25:03 +00:00
// Monkey-patch the fs module.
require('ELECTRON_ASAR').wrapFsWithAsar(require('fs'))
2016-03-25 19:57:17 +00:00
}
})()