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:
parent
fe78c17ea6
commit
0933a7d1b2
1 changed files with 7 additions and 5 deletions
|
@ -1,6 +1,8 @@
|
||||||
fs = require 'fs'
|
vm = require 'vm'
|
||||||
|
|
||||||
copied = {}
|
# Execute the 'fs.js' and pass the 'exports' to it.
|
||||||
copied[k] = v for k, v of fs
|
source = '(function (exports, require, module, __filename, __dirname) { ' +
|
||||||
|
process.binding('natives').fs +
|
||||||
module.exports = copied
|
'\n});'
|
||||||
|
fn = vm.runInThisContext source, { filename: 'fs.js' }
|
||||||
|
fn exports, require, module
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue