module: fix unintended mutation

Refs: https://github.com/nodejs/node/pull/46061#issuecomment-1372246648
PR-URL: https://github.com/nodejs/node/pull/46108
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
This commit is contained in:
Antoine du Hamel authored and GitHub committed 2023-01-07 15:36:51 +00:00
1 parent 021f72618c
commit 693b6fbeac
2 files changed
+10 -5

No files matched your search

+5 -5
View File
@@ -29,6 +29,7 @@ const {
ArrayPrototypeJoin,
ArrayPrototypeMap,
ArrayPrototypePush,
ArrayPrototypePushApply,
ArrayPrototypeSlice,
ArrayPrototypeSplice,
ArrayPrototypeUnshift,
@@ -668,12 +669,11 @@ Module._findPath = function(request, paths, isMain) {
return filename;
}
if (exts === undefined) {
exts = [''];
} else {
ArrayPrototypeUnshift(exts, '');
const extensions = [''];
if (exts !== undefined) {
ArrayPrototypePushApply(extensions, exts);
}
reportModuleNotFoundToWatchMode(basePath, exts);
reportModuleNotFoundToWatchMode(basePath, extensions);
}
return false;
+5
View File
@@ -98,3 +98,8 @@ assert.strictEqual(
require.resolve('./printA.js', {}),
require.resolve('./printA.js')
);
assert.strictEqual(
require.resolve('no_index/'),
path.join(__dirname, 'node_modules', 'no_index', 'lib', 'index.js'),
)