Skip to content
This repository was archived by the owner on Apr 16, 2020. It is now read-only.

Commit 6bb7e1a

Browse files
committed
esm: fix tests
1 parent 50437ce commit 6bb7e1a

18 files changed

Lines changed: 23 additions & 23 deletions

lib/internal/modules/esm/default_resolve.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const internalFS = require('internal/fs/utils');
44
const { NativeModule } = require('internal/bootstrap/loaders');
55
const { extname } = require('path');
6-
const { realpathSync } = require('fs');
6+
const { readFileSync, realpathSync } = require('fs');
77
const { getOptionValue } = require('internal/options');
88

99
const preserveSymlinks = getOptionValue('--preserve-symlinks');

lib/internal/modules/esm/detect_type.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function detectType(source, filename) {
2727
token.label !== '(' &&
2828
// Also ensure that the keyword we just saw wasn't an allowed use
2929
// of a reserved word as a property name; see
30-
// test/fixtures/es-modules/type-auto-scope/
30+
// test/fixtures/es-modules/entry-type-auto-scope/
3131
// cjs-with-property-named-import.js
3232
!(prevPrevToken && prevPrevToken.label === '.') &&
3333
token.label !== ':')

src/node_options.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
112112
errors->push_back("--entry-type requires "
113113
"--experimental-modules to be enabled");
114114
}
115-
if (module_type != "commonjs" && module_type != "module") {
116-
errors->push_back("--entry-type must \"module\" or \"commonjs\"");
115+
if (module_type != "commonjs" && module_type != "module" &&
116+
module_type != "auto") {
117+
errors->push_back("--entry-type must be "
118+
"\"module\" or \"commonjs\" or \"auto\"");
117119
}
118120
}
119121

test/es-module/test-esm-type-auto.js renamed to test/es-module/test-esm-entry-type-auto.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,23 @@ expect('syntax-error-2.js', 'SyntaxError', true);
2424

2525
function expect(file, want, wantsError = false) {
2626
const argv = [
27-
require.resolve(`../fixtures/es-modules/type-auto-scope/${file}`)
27+
require.resolve(`../fixtures/es-modules/entry-type-auto-scope/${file}`)
2828
];
29-
['--type=auto', '-a'].forEach((opt) => {
29+
const opts = {
3030
// TODO: Remove when --experimental-modules is unflagged
31-
opt = `--experimental-modules ${opt}`;
32-
const opts = {
33-
env: { ...process.env, NODE_OPTIONS: opt },
34-
maxBuffer: 1e6,
35-
};
36-
exec(process.execPath, argv, opts,
37-
common.mustCall((err, stdout, stderr) => {
38-
if (wantsError) {
39-
stdout = stderr;
40-
} else {
41-
assert.ifError(err);
42-
}
43-
if (stdout.includes(want)) return;
44-
assert.fail(
45-
`For ${file}, failed to find ${want} in: <\n${stdout}\n>`);
46-
}));
47-
});
31+
env: { ...process.env,
32+
NODE_OPTIONS: '--experimental-modules --entry-type=auto' },
33+
maxBuffer: 1e6,
34+
};
35+
exec(process.execPath, argv, opts,
36+
common.mustCall((err, stdout, stderr) => {
37+
if (wantsError) {
38+
stdout = stderr;
39+
} else {
40+
assert.ifError(err);
41+
}
42+
if (stdout.includes(want)) return;
43+
assert.fail(
44+
`For ${file}, failed to find ${want} in: <\n${stdout}\n>`);
45+
}));
4846
}

test/fixtures/es-modules/type-auto-scope/ambiguous-with-import-expression.js renamed to test/fixtures/es-modules/entry-type-auto-scope/ambiguous-with-import-expression.js

File renamed without changes.

test/fixtures/es-modules/type-auto-scope/cjs-with-import-expression.js renamed to test/fixtures/es-modules/entry-type-auto-scope/cjs-with-import-expression.js

File renamed without changes.

test/fixtures/es-modules/type-auto-scope/cjs-with-property-named-export.js renamed to test/fixtures/es-modules/entry-type-auto-scope/cjs-with-property-named-export.js

File renamed without changes.

test/fixtures/es-modules/type-auto-scope/cjs-with-property-named-import.js renamed to test/fixtures/es-modules/entry-type-auto-scope/cjs-with-property-named-import.js

File renamed without changes.

test/fixtures/es-modules/type-auto-scope/cjs-with-require.js renamed to test/fixtures/es-modules/entry-type-auto-scope/cjs-with-require.js

File renamed without changes.

test/fixtures/es-modules/type-auto-scope/cjs-with-string-containing-import.js renamed to test/fixtures/es-modules/entry-type-auto-scope/cjs-with-string-containing-import.js

File renamed without changes.

0 commit comments

Comments
 (0)