mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
test: fix require-deps-deprecation for installed deps
Test test-require-deps-deprecation.js was failing when user already had node installed with acorn in require.resolve range. Modified test to acknowledge the possibility and throw only if acorn is found in the deps directory. PR-URL: https://github.com/nodejs/node/pull/17848 Fixes: https://github.com/nodejs/node/issues/17148 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
committed by
Anatoli Papirovski
parent
e6a401e0ae
commit
30892c8fb4
@@ -39,6 +39,17 @@ for (const m of deprecatedModules) {
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
// Instead of checking require, check that resolve isn't pointing toward a
|
||||
// built-in module, as user might already have node installed with acorn in
|
||||
// require.resolve range.
|
||||
// Ref: https://github.com/nodejs/node/issues/17148
|
||||
for (const m of deps) {
|
||||
assert.throws(() => { require(m); }, /^Error: Cannot find module/);
|
||||
let path;
|
||||
try {
|
||||
path = require.resolve(m);
|
||||
} catch (err) {
|
||||
assert.ok(err.toString().startsWith('Error: Cannot find module '));
|
||||
continue;
|
||||
}
|
||||
assert.notStrictEqual(path, m);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user