-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(node): add
Module.runMain()
(#19080)
This PR adds the missing `Module.runMain()` function which is required for tools like `ts-node`. Fixes #19033
- Loading branch information
1 parent
610936f
commit 56a9a2a
Showing
4 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
globalThis.foo = 42; |
15 changes: 15 additions & 0 deletions
15
cli/tests/node_compat/test/parallel/test-module-run-main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// deno-fmt-ignore-file | ||
// deno-lint-ignore-file | ||
|
||
"use strict"; | ||
|
||
const Module = require("module"); | ||
const assert = require("assert/strict"); | ||
const path = require("path"); | ||
|
||
const file = path.join(__dirname, "..", "fixtures", "run-main.js"); | ||
process.argv = [process.argv[0], file]; | ||
Module.runMain(); | ||
|
||
// The required file via `Module.runMain()` sets this global | ||
assert.equal(globalThis.foo, 42); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters