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>
This commit is contained in:
parent
eb089e7ccd
commit
f17b9494e1
@ -221,8 +221,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…
x
Reference in New Issue
Block a user