Browse Source

doc: update vm.runInDebugContext() example

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: https://github.com/nodejs/node/issues/4862
PR-URL: https://github.com/nodejs/node/pull/6757
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
v4.x
Ben Noordhuis 9 years ago
committed by Myles Borins
parent
commit
50f02bd8d6
  1. 4
      doc/api/vm.markdown

4
doc/api/vm.markdown

@ -212,8 +212,10 @@ a separate process.
context. The primary use case is to get access to the V8 debug object: context. The primary use case is to get access to the V8 debug object:
```js ```js
const vm = require('vm');
const Debug = vm.runInDebugContext('Debug'); 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 Note that the debug context and object are intrinsically tied to V8's debugger

Loading…
Cancel
Save