summaryrefslogtreecommitdiff
path: root/test/es-module
diff options
context:
space:
mode:
authorRongjian Zhang <pd4d10@gmail.com>2019-11-22 14:29:30 +0800
committerRich Trott <rtrott@gmail.com>2019-11-28 10:22:53 -0800
commitf5ef7cd22231987a73af9f02cc5f6c80b6dbbd9b (patch)
treef5385035b45fbd892b1505c342c360866b959840 /test/es-module
parent4d73fd39489c6c2742cc16107f00dc81c7239706 (diff)
downloadandroid-node-v8-f5ef7cd22231987a73af9f02cc5f6c80b6dbbd9b.tar.gz
android-node-v8-f5ef7cd22231987a73af9f02cc5f6c80b6dbbd9b.tar.bz2
android-node-v8-f5ef7cd22231987a73af9f02cc5f6c80b6dbbd9b.zip
module: fix specifier resolution algorithm
Fixes: https://github.com/nodejs/node/issues/30520 PR-URL: https://github.com/nodejs/node/pull/30574 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'test/es-module')
-rw-r--r--test/es-module/test-esm-specifiers.mjs22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/es-module/test-esm-specifiers.mjs b/test/es-module/test-esm-specifiers.mjs
index 3e7bc18196..fdf9e5b25e 100644
--- a/test/es-module/test-esm-specifiers.mjs
+++ b/test/es-module/test-esm-specifiers.mjs
@@ -1,6 +1,9 @@
// Flags: --es-module-specifier-resolution=node
import { mustNotCall } from '../common/index.mjs';
import assert from 'assert';
+import path from 'path';
+import { spawn } from 'child_process';
+import { fileURLToPath } from 'url';
// commonJS index.js
import commonjs from '../fixtures/es-module-specifiers/package-type-commonjs';
@@ -33,3 +36,22 @@ async function main() {
}
main().catch(mustNotCall);
+
+// Test path from command line arguments
+[
+ 'package-type-commonjs',
+ 'package-type-module',
+ '/',
+ '/index',
+].forEach((item) => {
+ const modulePath = path.join(
+ fileURLToPath(import.meta.url),
+ '../../fixtures/es-module-specifiers',
+ item,
+ );
+ spawn(process.execPath,
+ ['--es-module-specifier-resolution=node', modulePath],
+ { stdio: 'inherit' }).on('exit', (code) => {
+ assert.strictEqual(code, 0);
+ });
+});