mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Evaluate the "fs.js" in original-fs
Some high-level APIs in fs are using low-level APIs via "fs.xxx", which will be overriden by our asar wrappers, so just shadow-copy those methods is not enough. By evaluating the whole "fs.js" we can make sure original-fs is not polluted by the asar wrappers. Fixes #782.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
fs = require 'fs'
|
||||
vm = require 'vm'
|
||||
|
||||
copied = {}
|
||||
copied[k] = v for k, v of fs
|
||||
|
||||
module.exports = copied
|
||||
# Execute the 'fs.js' and pass the 'exports' to it.
|
||||
source = '(function (exports, require, module, __filename, __dirname) { ' +
|
||||
process.binding('natives').fs +
|
||||
'\n});'
|
||||
fn = vm.runInThisContext source, { filename: 'fs.js' }
|
||||
fn exports, require, module
|
||||
|
||||
Reference in New Issue
Block a user