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 authored and Myles Borins committed May 18, 2016
1 parent 37a9815 commit a2339e4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doc/api/vm.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,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 a2339e4

Please sign in to comment.