forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "fs: make callback mandatory to all async functions"
This reverts commit 9359de9. Original Commit Message: The "fs" module has two functions called `maybeCallback` and `makeCallback`, as of now. The `maybeCallback` creates a default function to report errors, if the parameter passed is not a function object. Basically, if the callback is omitted in some cases, this function is used to create a default callback function. The `makeCallback`, OTOH, creates a default function only if the parameter passed is `undefined`, and if it is not a function object it will throw an `Error`. This patch removes the `maybeCallback` function and makes the callback function argument mandatory for all the async functions. PR-URL: nodejs#7168 Reviewed-By: Trevor Norris <trev.norris@gmail.com> PR-URL: nodejs#7846 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
10 changed files
with
143 additions
and
73 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
require('fs').readFile('/'); // throws EISDIR |
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
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
This file was deleted.
Oops, something went wrong.
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,34 @@ | ||
'use strict'; | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
var exec = require('child_process').exec; | ||
var path = require('path'); | ||
|
||
// `fs.readFile('/')` does not fail on FreeBSD, because you can open and read | ||
// the directory there. | ||
if (process.platform === 'freebsd') { | ||
common.skip('platform not supported.'); | ||
return; | ||
} | ||
|
||
function test(env, cb) { | ||
var filename = path.join(common.fixturesDir, 'test-fs-readfile-error.js'); | ||
var execPath = '"' + process.execPath + '" "' + filename + '"'; | ||
var options = { env: Object.assign(process.env, env) }; | ||
exec(execPath, options, function(err, stdout, stderr) { | ||
assert(err); | ||
assert.equal(stdout, ''); | ||
assert.notEqual(stderr, ''); | ||
cb('' + stderr); | ||
}); | ||
} | ||
|
||
test({ NODE_DEBUG: '' }, common.mustCall(function(data) { | ||
assert(/EISDIR/.test(data)); | ||
assert(!/test-fs-readfile-error/.test(data)); | ||
})); | ||
|
||
test({ NODE_DEBUG: 'fs' }, common.mustCall(function(data) { | ||
assert(/EISDIR/.test(data)); | ||
assert(/test-fs-readfile-error/.test(data)); | ||
})); |
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