mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
efce655c0f
Previously `internal/bootstrap/pre_execution.js` requires `internal/modules/cjs/loader.js` which in turn requires `internal/bootstrap/pre_execution.js`. This patch moves the entry point execution logic out of `pre_execution.js` and puts it into `internal/modules/run_main.js`. It also tests that `Module.runMain` can be monkey-patched before further deprecation/refactoring can be done. Also added an internal assertion `hasLoadedAnyUserCJSModule` for documentation purposes. PR-URL: https://github.com/nodejs/node/pull/30349 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
19 lines
533 B
JavaScript
19 lines
533 B
JavaScript
'use strict';
|
|
|
|
// This tests that module.runMain can be monkey patched using --require.
|
|
// TODO(joyeecheung): This probably should be deprecated.
|
|
|
|
require('../common');
|
|
const { path } = require('../common/fixtures');
|
|
const assert = require('assert');
|
|
const { spawnSync } = require('child_process');
|
|
|
|
const child = spawnSync(process.execPath, [
|
|
'--require',
|
|
path('monkey-patch-run-main.js'),
|
|
path('semicolon.js'),
|
|
]);
|
|
|
|
assert.strictEqual(child.status, 0);
|
|
assert(child.stdout.toString().includes('runMain is monkey patched!'));
|