mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix: load CLI configs with top-level await (#4100)
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
@@ -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')}'`,
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export default await Promise.resolve({
|
||||
breaks: true,
|
||||
});
|
||||
Reference in New Issue
Block a user