Redirect process.binding('natives').fs to global fs object

This commit is contained in:
Cheng Zhao 2015-01-31 23:47:47 -08:00
parent 0a393eaa1c
commit afd6f41e08
2 changed files with 6 additions and 1 deletions

View file

@ -2,7 +2,7 @@ vm = require 'vm'
# Execute the 'fs.js' and pass the 'exports' to it.
source = '(function (exports, require, module, __filename, __dirname) { ' +
process.binding('natives').fs +
process.binding('natives').originalFs +
'\n});'
fn = vm.runInThisContext source, { filename: 'fs.js' }
fn exports, require, module

View file

@ -39,3 +39,8 @@ if process.type is 'browser'
# Add support for asar packages.
asar = require './asar'
asar.wrapFsWithAsar fs
# Make graceful-fs work with asar.
source = process.binding 'natives'
source.originalFs = source.fs
source.fs = "module.exports = require('fs');"