Skip to content

Commit

Permalink
doc: update vm.runInDebugContext() example
Browse files Browse the repository at this point in the history
The debugger needs to be active now before one is allowed to query the
list of scripts.  Replace the example with one that works without
installing a debug event listener first.

Fixes: #4862
PR-URL: #6757
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
  • Loading branch information
bnoordhuis committed May 16, 2016
1 parent eb089e7 commit f17b949
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doc/api/vm.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ a separate process.
context. The primary use case is to get access to the V8 debug object:

```js
const vm = require('vm');
const Debug = vm.runInDebugContext('Debug');
Debug.scripts().forEach((script) => { console.log(script.name); });
console.log(Debug.findScript(process.emit).name); // 'events.js'
console.log(Debug.findScript(process.exit).name); // 'internal/process.js'
```

Note that the debug context and object are intrinsically tied to V8's debugger
Expand Down

0 comments on commit f17b949

Please sign in to comment.