Skip to content

Commit

Permalink
Revert "fs: deprecate fs.read's string interface"
Browse files Browse the repository at this point in the history
This reverts commit 1124de2
which landed in nodejs#4525

This commit has broken both npm + node-gyp

How did it break npm?

Deprecating fs.read's string interface includes `internal/util`
Currently npm's dep tree includes an old version of graceful-fs
that is monkey patching fs. As such everything explodes when
trying to require `internal/util`

nodejs#5102 is waiting for review
but has not landed. We should revert ASAP to fix master while
we decide what to do.
  • Loading branch information
Myles Borins committed Feb 9, 2016
1 parent 1693349 commit 3e32ff5
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const isWindows = process.platform === 'win32';

const DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
const errnoException = util._errnoException;
const printDeprecation = require('internal/util').printDeprecationMessage;

function throwOptionsError(options) {
throw new TypeError('Expected options to be either an object or a string, ' +
Expand Down Expand Up @@ -585,14 +584,9 @@ fs.openSync = function(path, flags, mode) {
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
};

var readWarned = false;
fs.read = function(fd, buffer, offset, length, position, callback) {
if (!(buffer instanceof Buffer)) {
// legacy string interface (fd, length, position, encoding, callback)
readWarned = printDeprecation('fs.read\'s legacy String interface ' +
'is deprecated. Use the Buffer API as ' +
'mentioned in the documentation instead.',
readWarned);
const cb = arguments[4];
const encoding = arguments[3];

Expand Down Expand Up @@ -642,17 +636,12 @@ function tryToStringWithEnd(buf, encoding, end, callback) {
callback(e, buf, end);
}

var readSyncWarned = false;
fs.readSync = function(fd, buffer, offset, length, position) {
var legacy = false;
var encoding;

if (!(buffer instanceof Buffer)) {
// legacy string interface (fd, length, position, encoding, callback)
readSyncWarned = printDeprecation('fs.readSync\'s legacy String interface' +
'is deprecated. Use the Buffer API as ' +
'mentioned in the documentation instead.',
readSyncWarned);
legacy = true;
encoding = arguments[3];

Expand Down

0 comments on commit 3e32ff5

Please sign in to comment.