Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fs: deprecate fs.read's string interface" #5163

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
33 changes: 33 additions & 0 deletions test/parallel/test-npm-install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';
const common = require('../common');

const path = require('path');
const spawn = require('child_process').spawn;
const assert = require('assert');

common.refreshTmpDir();

const npmPath = path.join(
common.testDir,
'..',
'deps',
'npm',
'bin',
'npm-cli.js'
);

const args = [
npmPath,
'install'
];

const proc = spawn(process.execPath, args, {
cwd: common.tmpDir
});

proc.on('exit', function(code) {
// npm install in tmpDir should be essentially a no-op.
// If npm is not broken the process should always exit 0.
// Assert that there are no obvious failures.
assert.equal(code, 0, 'npm install should run wihtout an error');
});