Skip to content

Commit

Permalink
module: fixup lint and test regressions
Browse files Browse the repository at this point in the history
PR-URL: #30802
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: João Reis <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
guybedford authored and targos committed Dec 9, 2019
1 parent bd2f127 commit a7ec78f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ Module.prototype._compile = function(content, filename) {
} catch {
// We only expect this codepath to be reached in the case of a
// preloaded module (it will fail earlier with the main entry)
assert(Array.isArray(getOptionValue('--require')));
assert(ArrayIsArray(getOptionValue('--require')));
}
} else {
resolvedArgv = 'repl';
Expand Down
11 changes: 4 additions & 7 deletions test/es-module/test-cjs-esm-warn.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ child.on('close', common.mustCall((code, signal) => {
assert.strictEqual(code, 1);
assert.strictEqual(signal, null);

assert.ok(stderr.indexOf(
assert.ok(stderr.replace(/\r/g, '').includes(
`Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ${required}` +
'\nrequire() of ES modules is not supported.\nrequire() of ' +
`${required} from ${requiring} ` +
Expand All @@ -35,10 +35,7 @@ child.on('close', common.mustCall((code, signal) => {
'files in that package scope as ES modules.\nInstead rename ' +
`${basename} to end in .cjs, change the requiring code to use ` +
'import(), or remove "type": "module" from ' +
`${pjson}.\n`) !== -1);
assert.ok(stderr.indexOf(
'Error [ERR_REQUIRE_ESM]: Must use import to load ES Module') !== -1);

assert.strictEqual(
stderr.match(/Must use import to load ES Module/g).length, 1);
`${pjson}.\n`));
assert.ok(stderr.includes(
'Error [ERR_REQUIRE_ESM]: Must use import to load ES Module'));
}));
4 changes: 1 addition & 3 deletions test/es-module/test-esm-specifiers-both-flags.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ const expectedError =
const flags = '--es-module-specifier-resolution=node ' +
'--experimental-specifier-resolution=node';

exec(`${process.execPath} ${flags}`, {
timeout: 300
}, mustCall((error) => {
exec(`${process.execPath} ${flags}`, mustCall((error) => {
assert(error.message.includes(expectedError));
}));

0 comments on commit a7ec78f

Please sign in to comment.