forked from isaacs/node-graceful-fs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix fs module process.binding hackery
Fix the horrible atrocity introduced in 08471b2. Previously it would evaluate the code directly through process.binding(), and it now creates a new Object with the prototype being the real fs module, exported by core. Ref: nodejs/node#2026
- Loading branch information
1 parent
460834a
commit 1bf13d3
Showing
3 changed files
with
11 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1 @@ | ||
// eeeeeevvvvviiiiiiillllll | ||
// more evil than monkey-patching the native builtin? | ||
// Not sure. | ||
|
||
var mod = require("module") | ||
var pre = '(function (exports, require, module, __filename, __dirname) { ' | ||
var post = '});' | ||
var src = pre + process.binding('natives').fs + post | ||
var vm = require('vm') | ||
var fn = vm.runInThisContext(src) | ||
fn(exports, require, module, __filename, __dirname) | ||
module.exports = Object.create(require('fs')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var test = require('tap').test | ||
var realfs = require('fs') | ||
var fs = require('../') | ||
|
||
test('module assignment should not leak', function (t) { | ||
t.plan(1) | ||
|
||
fs.abc = 3 | ||
t.equal(realfs.abc, undefined) | ||
}) |