From 614742b67faed1054fc08ba8f8836cb182f2efae Mon Sep 17 00:00:00 2001 From: Josh Gavant Date: Thu, 9 Feb 2017 15:12:32 -0800 Subject: [PATCH] lib: deprecate node --debug at runtime PR-URL: https://github.com/nodejs/node/pull/11275 Backport-of: https://github.com/nodejs/node/pull/10970 Reviewed-By: James M Snell --- lib/_debug_agent.js | 4 ++++ test/parallel/test-debug-port-from-cmdline.js | 23 +++++++++++++++---- test/parallel/test-debug-signal-cluster.js | 3 ++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/_debug_agent.js b/lib/_debug_agent.js index eedca7ef5843bb..c731ca374b5e87 100644 --- a/lib/_debug_agent.js +++ b/lib/_debug_agent.js @@ -1,5 +1,9 @@ 'use strict'; +process.emitWarning( + 'node --debug is deprecated. Please use node --inspect instead.', + 'DeprecationWarning'); + const assert = require('assert'); const net = require('net'); const util = require('util'); diff --git a/test/parallel/test-debug-port-from-cmdline.js b/test/parallel/test-debug-port-from-cmdline.js index 53f35877a2f382..fe22473d56625e 100644 --- a/test/parallel/test-debug-port-from-cmdline.js +++ b/test/parallel/test-debug-port-from-cmdline.js @@ -2,12 +2,19 @@ const common = require('../common'); const assert = require('assert'); const spawn = require('child_process').spawn; +const os = require('os'); const debugPort = common.PORT; const args = ['--interactive', '--debug-port=' + debugPort]; const childOptions = { stdio: ['pipe', 'pipe', 'pipe', 'ipc'] }; const child = spawn(process.execPath, args, childOptions); +const reDeprecationWarning = new RegExp( + /^\(node:\d+\) DeprecationWarning: /.source + + /node --debug is deprecated. /.source + + /Please use node --inspect instead.$/.source +); + child.stdin.write("process.send({ msg: 'childready' });\n"); child.stderr.on('data', function(data) { @@ -37,12 +44,20 @@ function processStderrLine(line) { } function assertOutputLines() { - const expectedLines = [ - 'Starting debugger agent.', - 'Debugger listening on 127.0.0.1:' + debugPort, + // need a var so can swap the first two lines in following + // eslint-disable-next-line no-var + var expectedLines = [ + /^Starting debugger agent.$/, + reDeprecationWarning, + new RegExp(`^Debugger listening on 127.0.0.1:${debugPort}$`) ]; + if (os.platform() === 'win32') { + expectedLines[1] = expectedLines[0]; + expectedLines[0] = reDeprecationWarning; + } + assert.strictEqual(outputLines.length, expectedLines.length); for (let i = 0; i < expectedLines.length; i++) - assert(expectedLines[i].includes(outputLines[i])); + assert(expectedLines[i].test(outputLines[i])); } diff --git a/test/parallel/test-debug-signal-cluster.js b/test/parallel/test-debug-signal-cluster.js index 89b3ca456d3248..059a3c2433a72b 100644 --- a/test/parallel/test-debug-signal-cluster.js +++ b/test/parallel/test-debug-signal-cluster.js @@ -8,7 +8,8 @@ const path = require('path'); const port = common.PORT; const serverPath = path.join(common.fixturesDir, 'clustered-server', 'app.js'); -const args = [`--debug-port=${port}`, serverPath]; +// cannot use 'Flags: --no-deprecation' since it doesn't effect child +const args = [`--debug-port=${port}`, '--no-deprecation', serverPath]; const options = { stdio: ['inherit', 'inherit', 'pipe', 'ipc'] }; const child = spawn(process.execPath, args, options);