diff --git a/lib/binding.js b/lib/binding.js index 967d56b6..a2dfa4bd 100644 --- a/lib/binding.js +++ b/lib/binding.js @@ -27,7 +27,11 @@ function maybeCallback(callback, thisArg, func) { err = e; } process.nextTick(function() { - callback(err, val); + if (val === undefined) { + callback(err); + } else { + callback(err, val); + } }); } else { return func.call(thisArg); diff --git a/test/lib/index.spec.js b/test/lib/index.spec.js index ea51b2a9..9de4cbbc 100644 --- a/test/lib/index.spec.js +++ b/test/lib/index.spec.js @@ -1637,6 +1637,20 @@ describe('Mocking the file system', function() { }); }); + it('calls callback with a single argument on success', function(done) { + fs.mkdir('parent/arity', function(err) { + assert.equal(arguments.length, 1); + done(); + }); + }); + + it('calls callback with a single argument on failure', function(done) { + fs.mkdir('parent', function(err) { + assert.instanceOf(err, Error); + done(); + }); + }); + }); describe('fs.mkdirSync(path, [mode])', function() {