Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 50f02bd

Browse filesBrowse files
bnoordhuisMyles Borins
authored andcommitted
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: #4862 PR-URL: #6757 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
1 parent 773ea20 commit 50f02bd
Copy full SHA for 50f02bd

File tree

Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed
Open diff view settings
Collapse file

‎doc/api/vm.markdown‎

Copy file name to clipboardExpand all lines: doc/api/vm.markdown
+3-1Lines changed: 3 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,10 @@ a separate process.
212212
context. The primary use case is to get access to the V8 debug object:
213213

214214
```js
215+
const vm = require('vm');
215216
const Debug = vm.runInDebugContext('Debug');
216-
Debug.scripts().forEach((script) => { console.log(script.name); });
217+
console.log(Debug.findScript(process.emit).name); // 'events.js'
218+
console.log(Debug.findScript(process.exit).name); // 'internal/process.js'
217219
```
218220

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.