Skip to content

Commit 13d6651

Browse files
DYefimovnovemberborn
andauthoredMar 1, 2020
Add debug --host option
Allow binding the inspector to a different address or hostname. Co-authored-by: Mark Wubben <mark@novemberborn.net>
1 parent 8630636 commit 13d6651

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed
 

‎docs/recipes/debugging-with-chrome-devtools.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ Run with the `--break` option to ensure the DevTools hit a breakpoint right befo
2222
npx ava debug --break test.js
2323
```
2424

25-
You can also customize the port. It defaults to `9229`:
25+
By default the inspector listens on `127.0.0.1:9229`. You can customize the host and the port:
2626

2727
```console
28-
npx ava debug --port 9230 test.js
28+
npx ava debug --host 0.0.0.0 --port 9230 test.js
2929
```
3030

31-
You'll have to add a connection for this port in the *Connection* tab. AVA only binds to `localhost`.
31+
You'll have to add a connection for this port in the *Connection* tab.

‎lib/cli.js

+6
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ exports.run = async () => { // eslint-disable-line complexity
131131
description: 'Break before the test file is loaded',
132132
type: 'boolean'
133133
},
134+
host: {
135+
default: '127.0.0.1',
136+
description: 'Address or hostname through which you can connect to the inspector',
137+
type: 'string'
138+
},
134139
port: {
135140
default: 9229,
136141
description: 'Port on which you can connect to the inspector',
@@ -145,6 +150,7 @@ exports.run = async () => { // eslint-disable-line complexity
145150
debug = {
146151
break: argv.break === true,
147152
files: argv.pattern,
153+
host: argv.host,
148154
port: argv.port
149155
};
150156
})

‎lib/worker/subprocess.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ ipc.options.then(async options => {
189189
dependencyTracking.install(testPath);
190190

191191
if (options.debug) {
192-
require('inspector').open(options.debug.port, '127.0.0.1', true);
192+
require('inspector').open(options.debug.port, options.debug.host, true);
193193
if (options.debug.break) {
194194
debugger; // eslint-disable-line no-debugger
195195
}

0 commit comments

Comments
 (0)
Please sign in to comment.