Don't touch global fs object in graceful-fs

This commit is contained in:
Cheng Zhao 2015-02-01 14:04:40 -08:00
parent 3f8ad3bf75
commit 0c0a6bd939

View file

@ -43,4 +43,13 @@ asar.wrapFsWithAsar fs
# Make graceful-fs work with asar.
source = process.binding 'natives'
source.originalFs = source.fs
source.fs = "module.exports = require('fs');"
source.fs = """
var src = '(function (exports, require, module, __filename, __dirname) { ' +
process.binding('natives').originalFs +
' });';
var vm = require('vm');
var fn = vm.runInThisContext(src, { filename: 'fs.js' });
fn(exports, require, module);
var asar = require('#{__dirname}/asar');
asar.wrapFsWithAsar(exports);
"""