From 8b61c0c11d51c66d0d93e7417f7ec734a8876202 Mon Sep 17 00:00:00 2001 From: Josh Gavant Date: Wed, 14 Dec 2016 16:43:30 -0800 Subject: [PATCH 1/2] src,lib: deprecate --debug and debug options Print a warning if --debug or debug are used on the command line. PR-URL: Reviewed-By: Reviewed-By: --- lib/_debugger.js | 3 ++- src/node.cc | 1 - src/node_debug_options.cc | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/_debugger.js b/lib/_debugger.js index d3bf1f9ffa2dab..96de145b8729e9 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -12,7 +12,7 @@ const assert = require('assert'); const spawn = require('child_process').spawn; const Buffer = require('buffer').Buffer; -exports.start = function(argv, stdin, stdout) { +exports.start = function start(argv, stdin, stdout) { argv || (argv = process.argv.slice(2)); if (argv.length < 1) { @@ -27,6 +27,7 @@ exports.start = function(argv, stdin, stdout) { stdout = stdout || process.stdout; const args = [`--debug-brk=${exports.port}`].concat(argv); + console.error('`node debug` is deprecated, use `node inspect` instead.\n'); const interface_ = new Interface(stdin, stdout, args); stdin.resume(); diff --git a/src/node.cc b/src/node.cc index 3147a90d3e3844..7ba85f39a14d10 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3460,7 +3460,6 @@ static void PrintHelp() { // XXX: If you add an option here, please also add it to doc/node.1 and // doc/api/cli.md printf("Usage: node [options] [ -e script | script.js ] [arguments] \n" - " node debug script.js [arguments] \n" "\n" "Options:\n" " -v, --version print Node.js version\n" diff --git a/src/node_debug_options.cc b/src/node_debug_options.cc index 5681e3d46edaca..2def6b94eaf265 100644 --- a/src/node_debug_options.cc +++ b/src/node_debug_options.cc @@ -92,6 +92,9 @@ bool DebugOptions::ParseOption(const std::string& option) { if (option_name == "--debug") { debugger_enabled_ = true; + fprintf(stderr, + "--debug is deprecated and will be removed in " + "a future version. Please use --inspect instead.\n\n"); } else if (option_name == "--debug-brk") { debugger_enabled_ = true; wait_connect_ = true; From a61368e1b4dea0f04ca0c4ca43268056ffe2fb08 Mon Sep 17 00:00:00 2001 From: Josh Gavant Date: Wed, 14 Dec 2016 17:31:49 -0800 Subject: [PATCH 2/2] squash: update tests --- test/parallel/test-debugger-pid.js | 1 - test/parallel/test-debugger-util-regression.js | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-debugger-pid.js b/test/parallel/test-debugger-pid.js index 2b81da700f50a0..7f82080a891229 100644 --- a/test/parallel/test-debugger-pid.js +++ b/test/parallel/test-debugger-pid.js @@ -19,7 +19,6 @@ var onData = function(data) { }); }; interfacer.stdout.on('data', onData); -interfacer.stderr.on('data', onData); var lineCount = 0; interfacer.on('line', function(line) { diff --git a/test/parallel/test-debugger-util-regression.js b/test/parallel/test-debugger-util-regression.js index 07e52545814b14..b65aa8e6957954 100644 --- a/test/parallel/test-debugger-util-regression.js +++ b/test/parallel/test-debugger-util-regression.js @@ -9,6 +9,11 @@ const fixture = path.join( 'debugger-util-regression-fixture.js' ); +const deprecationWarning = [ + '`node debug` is deprecated, ', + 'use `node inspect` instead.\n\n' +].join(''); + const args = [ 'debug', `--port=${common.PORT}`, @@ -49,5 +54,6 @@ process.on('exit', (code) => { assert.strictEqual(code, 0, 'the program should exit cleanly'); assert.strictEqual(stdout.includes('{ a: \'b\' }'), true, 'the debugger should print the result of util.inspect'); - assert.strictEqual(stderr, '', 'stderr should be empty'); + assert.strictEqual(stderr, deprecationWarning, + 'stderr should print deprecation warning'); });