1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-13 19:12:20 -05:00
denoland-deno/cli/tests/node_compat/test/parallel/test-module-run-main.js
Marvin Hagemeister 56a9a2a990 feat(node): add Module.runMain() (#19080)
This PR adds the missing `Module.runMain()` function which is required
for tools like `ts-node`.

Fixes #19033
2023-05-11 17:26:29 -04:00

15 lines
393 B
JavaScript

// 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);