Skip to content

Commit

Permalink
Add debug --host option
Browse files Browse the repository at this point in the history
Allow binding the inspector to a different address or hostname.

Co-authored-by: Mark Wubben <mark@novemberborn.net>
  • Loading branch information
DYefimov and novemberborn committed Mar 1, 2020
1 parent 8630636 commit 13d6651
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions docs/recipes/debugging-with-chrome-devtools.md
Expand Up @@ -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.
6 changes: 6 additions & 0 deletions lib/cli.js
Expand Up @@ -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',
Expand All @@ -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
};
})
Expand Down
2 changes: 1 addition & 1 deletion lib/worker/subprocess.js
Expand Up @@ -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
}
Expand Down

0 comments on commit 13d6651

Please sign in to comment.