-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use util._extend instead of the eval evil
Fix #31
- Loading branch information
Showing
3 changed files
with
32 additions
and
11 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,5 @@ | ||
// eeeeeevvvvviiiiiiillllll | ||
// more evil than monkey-patching the native builtin? | ||
// Not sure. | ||
// extend the builtin so that our monkeypatchery doesn't | ||
// muck with things not using graceful-fs | ||
|
||
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) | ||
return fn(exports, require, module, __filename, __dirname) | ||
var util = require('util') | ||
module.exports = util._extend({}, 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,28 @@ | ||
var test = require('tap').test | ||
var gfs = require('../graceful-fs.js') | ||
var fs = require('fs') | ||
|
||
var gstat, fstat | ||
|
||
test('gfs.stat', function (t) { | ||
gfs.stat(__filename, function (er, st) { | ||
if (er) throw er | ||
gstat = st | ||
t.ok(st instanceof gfs.Stats, 'should instanceof gfs.Stats') | ||
t.end() | ||
}) | ||
}) | ||
|
||
test('fs.stat', function (t) { | ||
fs.stat(__filename, function (er, st) { | ||
if (er) throw er | ||
fstat = st | ||
t.ok(st instanceof fs.Stats, 'should instanceof fs.Stats') | ||
t.end() | ||
}) | ||
}) | ||
|
||
test('stats should match', function (t) { | ||
t.similar(gstat, fstat) | ||
t.end() | ||
}) |
34e473a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on 560aaf5, I'm curious if others are reporting
EMFILE
with3.0.3
. I have a case where things work with3.0.2
and fail with3.0.3
(EMFILE
). I'll open an issue if I can narrow it down a bit.34e473a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#34 includes a small script to reproduce one issue on Node 0.10.