diff --git a/fs.js b/fs.js index ae9fd6f..97dddb6 100644 --- a/fs.js +++ b/fs.js @@ -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')) diff --git a/test/readdir-sort.js b/test/readdir-sort.js index fe005aa..cb63a68 100644 --- a/test/readdir-sort.js +++ b/test/readdir-sort.js @@ -14,7 +14,6 @@ test("readdir reorder", function (t) { g.readdir("whatevers", function (er, files) { if (er) throw er - console.error(files) t.same(files, [ "a", "b", "z" ]) t.end() }) diff --git a/test/stat.js b/test/stat.js new file mode 100644 index 0000000..a91fc47 --- /dev/null +++ b/test/stat.js @@ -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() +})