Skip to content

Commit f7e2ba5

Browse files
committed
lib: Improving deprecation messages
Prefixing all the prefixing all the deprecation messages with `[node]` so that the readers will know where the message comes from.
1 parent 567a12e commit f7e2ba5

13 files changed

+28
-21
lines changed

lib/_http_outgoing.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -645,4 +645,4 @@ OutgoingMessage.prototype.flushHeaders = function() {
645645

646646
OutgoingMessage.prototype.flush = util.deprecate(function() {
647647
this.flushHeaders();
648-
}, 'flush is deprecated. Use flushHeaders instead.');
648+
}, '[node] OutgoingMessage.flush is deprecated. Use flushHeaders instead.');

lib/_stream_writable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ WritableState.prototype.getBuffer = function writableStateGetBuffer() {
121121
Object.defineProperty(WritableState.prototype, 'buffer', {
122122
get: util.deprecate(function() {
123123
return this.getBuffer();
124-
}, '_writableState.buffer is deprecated. Use ' +
124+
}, '[node] _writableState.buffer is deprecated. Use ' +
125125
'_writableState.getBuffer() instead.')
126126
});
127127

lib/buffer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ Buffer.prototype.get = util.deprecate(function get(offset) {
460460
if (offset < 0 || offset >= this.length)
461461
throw new RangeError('index out of range');
462462
return this[offset];
463-
}, '.get() is deprecated. Access using array indexes instead.');
463+
}, '[node] Buffer.get() is deprecated. Access using array indexes instead.');
464464

465465

466466
// XXX remove in v0.13
@@ -469,7 +469,7 @@ Buffer.prototype.set = util.deprecate(function set(offset, v) {
469469
if (offset < 0 || offset >= this.length)
470470
throw new RangeError('index out of range');
471471
return this[offset] = v;
472-
}, '.set() is deprecated. Set using array indexes instead.');
472+
}, '[node] Buffer.set() is deprecated. Set using array indexes instead.');
473473

474474

475475
// TODO(trevnorris): fix these checks to follow new standard

lib/child_process.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ var _deprecatedCustomFds = util.deprecate(function(options) {
272272
options.stdio = options.customFds.map(function(fd) {
273273
return fd === -1 ? 'pipe' : fd;
274274
});
275-
}, 'child_process: customFds option is deprecated, use stdio instead.');
275+
}, '[node] child_process.customFds option is deprecated, use stdio instead.');
276276

277277
function _convertCustomFds(options) {
278278
if (options && options.customFds && !options.stdio) {

lib/crypto.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,10 @@ function filterDuplicates(names) {
681681
// Legacy API
682682
exports.__defineGetter__('createCredentials', util.deprecate(function() {
683683
return require('tls').createSecureContext;
684-
}, 'createCredentials() is deprecated, use tls.createSecureContext instead'));
684+
}, '[node] crypto.createCredentials() is deprecated, ' +
685+
'use tls.createSecureContext instead'));
685686

686687
exports.__defineGetter__('Credentials', util.deprecate(function() {
687688
return require('tls').SecureContext;
688-
}, 'Credentials is deprecated, use tls.createSecureContext instead'));
689+
}, '[node] crypto.Credentials is deprecated, ' +
690+
'use tls.createSecureContext instead'));

lib/http.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ Client.prototype.request = function(method, path, headers) {
9292
};
9393

9494
exports.Client = util.deprecate(Client,
95-
'http.Client will be removed soon. Do not use it.');
95+
'[node] http.Client will be removed soon. Do not use it.');
9696

9797
exports.createClient = util.deprecate(function(port, host) {
9898
return new Client(port, host);
99-
}, 'http.createClient is deprecated. Use `http.request` instead.');
99+
}, '[node] http.createClient is deprecated. Use `http.request` instead.');

lib/module.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function tryExtensions(p, exts) {
122122

123123

124124
const noopDeprecateRequireDot = util.deprecate(function() {},
125-
'warning: require(\'.\') resolved outside the package directory. ' +
125+
'[node] warning: require(\'.\') resolved outside the package directory. ' +
126126
'This functionality is deprecated and will be removed soon.');
127127

128128

lib/net.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1081,10 +1081,11 @@ function Server(options, connectionListener) {
10811081
return null;
10821082
}
10831083
return self._connections;
1084-
}, 'connections property is deprecated. Use getConnections() method'),
1084+
}, '[node] Server.connections property is deprecated. ' +
1085+
'Use Server.getConnections() method'),
10851086
set: util.deprecate(function(val) {
10861087
return (self._connections = val);
1087-
}, 'connections property is deprecated. Use getConnections() method'),
1088+
}, '[node] Server.connections property is deprecated.'),
10881089
configurable: true, enumerable: false
10891090
});
10901091

@@ -1498,7 +1499,7 @@ function emitCloseNT(self) {
14981499

14991500
Server.prototype.listenFD = util.deprecate(function(fd, type) {
15001501
return this.listen({ fd: fd });
1501-
}, 'listenFD is deprecated. Use listen({fd: <number>}).');
1502+
}, '[node] Server.listenFD is deprecated. Use Server.listen({fd: <number>}).');
15021503

15031504
Server.prototype._setupSlave = function(socketList) {
15041505
this._usingSlaves = true;

lib/os.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ exports.tmpDir = exports.tmpdir;
4646

4747
exports.getNetworkInterfaces = util.deprecate(function() {
4848
return exports.networkInterfaces();
49-
}, 'getNetworkInterfaces is now called `os.networkInterfaces`.');
49+
}, '[node] os.getNetworkInterfaces is deprecated. ' +
50+
'Use `os.networkInterfaces` instead.');
5051

5152
exports.EOL = isWindows ? '\r\n' : '\n';
5253

lib/readline.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,8 @@ function codePointAt(str, index) {
14181418
return code;
14191419
}
14201420
exports.codePointAt = util.deprecate(codePointAt,
1421-
'codePointAt() is deprecated. Use String.prototype.codePointAt');
1421+
'[node] readline.codePointAt is deprecated. ' +
1422+
'Use String.prototype.codePointAt instead');
14221423

14231424

14241425
/**

lib/smalloc.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@ const smalloc = require('internal/smalloc');
44
const deprecate = require('util').deprecate;
55

66
exports.alloc =
7-
deprecate(smalloc.alloc, 'smalloc.alloc: Deprecated, use typed arrays');
7+
deprecate(smalloc.alloc,
8+
'[node] smalloc.alloc is deprecated, use typed arrays');
89

910
exports.copyOnto =
1011
deprecate(smalloc.copyOnto,
11-
'smalloc.copyOnto: Deprecated, use typed arrays');
12+
'[node] smalloc.copyOnto is deprecated, use typed arrays');
1213

1314
exports.dispose =
1415
deprecate(smalloc.dispose,
15-
'smalloc.dispose: Deprecated, use typed arrays');
16+
'[node] smalloc.dispose is deprecated, use typed arrays');
1617

1718
exports.hasExternalData =
1819
deprecate(smalloc.hasExternalData,
19-
'smalloc.hasExternalData: Deprecated, use typed arrays');
20+
'[node] smalloc.hasExternalData is deprecated, use typed arrays');
2021

2122
Object.defineProperty(exports, 'kMaxLength', {
2223
enumerable: true, value: smalloc.kMaxLength, writable: false

lib/sys.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ const util = require('util');
88

99
const setExports = util.deprecate(function() {
1010
module.exports = util;
11-
}, 'sys is deprecated. Use util instead.');
11+
}, '[node] sys module is deprecated. Use util module instead.');
1212

1313
setExports();

lib/tty.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ exports.setRawMode = util.deprecate(function(flag) {
1919
throw new Error('can\'t set raw mode on non-tty');
2020
}
2121
process.stdin.setRawMode(flag);
22-
}, 'tty.setRawMode: Use `process.stdin.setRawMode()` instead.');
22+
}, '[node] tty.setRawMode is depreacted. ' +
23+
'Use `process.stdin.setRawMode()` instead.');
2324

2425

2526
function ReadStream(fd, options) {

0 commit comments

Comments
 (0)