From 13d66519e7b69e810079673d6583dc7336a16ebe Mon Sep 17 00:00:00 2001 From: DYefimov Date: Sun, 1 Mar 2020 20:11:39 +0300 Subject: [PATCH] Add debug --host option Allow binding the inspector to a different address or hostname. Co-authored-by: Mark Wubben --- docs/recipes/debugging-with-chrome-devtools.md | 6 +++--- lib/cli.js | 6 ++++++ lib/worker/subprocess.js | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/recipes/debugging-with-chrome-devtools.md b/docs/recipes/debugging-with-chrome-devtools.md index da92d41b0..1a7f9ecd8 100644 --- a/docs/recipes/debugging-with-chrome-devtools.md +++ b/docs/recipes/debugging-with-chrome-devtools.md @@ -22,10 +22,10 @@ Run with the `--break` option to ensure the DevTools hit a breakpoint right befo npx ava debug --break test.js ``` -You can also customize the port. It defaults to `9229`: +By default the inspector listens on `127.0.0.1:9229`. You can customize the host and the port: ```console -npx ava debug --port 9230 test.js +npx ava debug --host 0.0.0.0 --port 9230 test.js ``` -You'll have to add a connection for this port in the *Connection* tab. AVA only binds to `localhost`. +You'll have to add a connection for this port in the *Connection* tab. diff --git a/lib/cli.js b/lib/cli.js index 6e0e68687..ff06c115a 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -131,6 +131,11 @@ exports.run = async () => { // eslint-disable-line complexity description: 'Break before the test file is loaded', type: 'boolean' }, + host: { + default: '127.0.0.1', + description: 'Address or hostname through which you can connect to the inspector', + type: 'string' + }, port: { default: 9229, description: 'Port on which you can connect to the inspector', @@ -145,6 +150,7 @@ exports.run = async () => { // eslint-disable-line complexity debug = { break: argv.break === true, files: argv.pattern, + host: argv.host, port: argv.port }; }) diff --git a/lib/worker/subprocess.js b/lib/worker/subprocess.js index b574e1403..b0e8f45c1 100644 --- a/lib/worker/subprocess.js +++ b/lib/worker/subprocess.js @@ -189,7 +189,7 @@ ipc.options.then(async options => { dependencyTracking.install(testPath); if (options.debug) { - require('inspector').open(options.debug.port, '127.0.0.1', true); + require('inspector').open(options.debug.port, options.debug.host, true); if (options.debug.break) { debugger; // eslint-disable-line no-debugger }