fix: load CLI configs with top-level await (#4100)

This commit is contained in:
pengboyu-dev
2026-09-28 21:03:58 -06:00
committed by GitHub
parent ef0704c584
commit c61543ed0f
3 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -180,7 +180,7 @@ export async function main(nodeProcess) {
// try require for json
markedConfig = require(configFile);
} catch(err) {
if (err.code !== 'ERR_REQUIRE_ESM') {
if (err.code !== 'ERR_REQUIRE_ESM' && err.code !== 'ERR_REQUIRE_ASYNC_MODULE') {
throw err;
}
// must import esm
+5
View File
@@ -116,6 +116,11 @@ describe('bin/marked', () => {
stdout: '<p>line1<br>line2</p>',
}));
it('config with top-level await', testInput({
args: ['--config', fixturePath('bin-config-await.mjs'), '-s', 'line1\nline2'],
stdout: '<p>line1<br>line2</p>',
}));
it('config not found', testInput({
args: ['--config', fixturePath('does-not-exist.js'), '-s', 'line1\nline2'],
stderr: `Cannot load config file '${fixturePath('does-not-exist.js')}'`,
+3
View File
@@ -0,0 +1,3 @@
export default await Promise.resolve({
breaks: true,
});