mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
esm: use correct error arguments
ERR_UNKNOWN_FILE_EXTENSION expects a single argument. This commit fixes the argument count. PR-URL: https://github.com/nodejs/node/pull/27763 Fixes: https://github.com/nodejs/node/issues/27761 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
This commit is contained in:
1 parent
7e750868c6
commit
80f30741bd
3 files changed
+15
-2
No files matched your search
@@ -91,8 +91,7 @@ function resolve(specifier, parentURL) {
|
||||
if (isMain)
|
||||
format = type === TYPE_MODULE ? 'module' : 'commonjs';
|
||||
else
|
||||
throw new ERR_UNKNOWN_FILE_EXTENSION(fileURLToPath(url),
|
||||
fileURLToPath(parentURL));
|
||||
throw new ERR_UNKNOWN_FILE_EXTENSION(fileURLToPath(url));
|
||||
}
|
||||
return { url: `${url}`, format };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const assert = require('assert');
|
||||
const { spawnSync } = require('child_process');
|
||||
const fixture = fixtures.path('/es-modules/import-invalid-ext.mjs');
|
||||
const child = spawnSync(process.execPath, ['--experimental-modules', fixture]);
|
||||
const errMsg = 'TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension';
|
||||
|
||||
assert.strictEqual(child.status, 1);
|
||||
assert.strictEqual(child.signal, null);
|
||||
assert.strictEqual(child.stdout.toString().trim(), '');
|
||||
assert(child.stderr.toString().includes(errMsg));
|
||||
@@ -0,0 +1 @@
|
||||
import './simple.wat';
|
||||
Reference in new issue
Block a user