From: Cheng Zhao Date: Mon, 19 Jan 2015 22:22:32 +0000 (-0800) Subject: Evaluate the "fs.js" in original-fs X-Git-Tag: v0.20.7~5 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=0933a7d1b234accf1ed73c7fbea0a54456205a8d;p=electron.git 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. --- diff --git a/atom/common/api/lib/original-fs.coffee b/atom/common/api/lib/original-fs.coffee index 5aefb357..38681683 100644 --- a/atom/common/api/lib/original-fs.coffee +++ b/atom/common/api/lib/original-fs.coffee @@ -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