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 <[email protected]>
Reviewed-By: Myles Borins <[email protected]>
  • Loading branch information
bnoordhuis authored and evanlucas committed May 17, 2016
1 parent 2273971 commit 688f563
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 688f563

Please sign in to comment.