fix: fix an original-fs regression introduced in 4.0 betas (#16028)

* fix: fix an original-fs regression introduced in 4.0 betas

* chore: remove cruft from earlier draft
This commit is contained in:
Charles Kerr 2018-12-12 15:32:53 -06:00 committed by GitHub
parent c65a0d90b8
commit f7528a0204
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,7 +3,13 @@
;(function () { // eslint-disable-line ;(function () { // eslint-disable-line
return function (source, require, asarSource) { return function (source, require, asarSource) {
// Expose fs module without asar support. // Expose fs module without asar support.
source['original-fs'] = source.fs
// 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')")
// Make asar.js accessible via "require". // Make asar.js accessible via "require".
source.ELECTRON_ASAR = asarSource source.ELECTRON_ASAR = asarSource