-
-
Notifications
You must be signed in to change notification settings - Fork 35.1k
lib: add process.loadedModules list
#61330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| 'use strict'; | ||
|
|
||
| require('../common'); | ||
| const assert = require('assert'); | ||
|
|
||
|
|
||
| for (const mod of process.loadedModules) { | ||
| assert.strictEqual(typeof mod, 'string'); | ||
| } | ||
|
|
||
| assert.strictEqual( | ||
| new Set(process.loadedModules).size, | ||
| process.loadedModules.length | ||
| ); | ||
|
|
||
| assert.ok(!process.loadedModules.includes('cluster')); | ||
| require('cluster'); | ||
| assert.ok(process.loadedModules.includes('cluster')); | ||
|
|
||
| assert.ok(Array.isArray(process.loadedModules)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there should be a little more on what's in that is actually what it should be :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it a better now? I'm not willing to test exact values in there to avoid flacky tests, am I wrong? |
||
| assert.throws(() => process.loadedModules = 'foo', /^TypeError: Cannot set property loadedModules of #<process> which has only a getter$/); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this handle #61276 (comment) and #61276 (comment) from Joyee had on your previous doc PR?
I think it specifically doesn't handle:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may have misunderstood Joyee's feedback, but I tought the
internal/prefix to be somehow reliable as it's almost as old as Node.js itself. Can you think of something else? :/