fix(cli): use file URL for config import (#3923)

This commit is contained in:
Nandan
2026-04-05 00:00:49 -06:00
committed by GitHub
parent a1c2617a37
commit 73e1f3f88e
3 changed files with 10 additions and 1 deletions
+2 -1
View File
@@ -10,6 +10,7 @@ import { promises } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { homedir } from 'node:os';
import { createRequire } from 'node:module';
import { pathToFileURL } from 'node:url';
import { marked } from '../lib/marked.esm.js';
const { access, readFile, writeFile } = promises;
@@ -183,7 +184,7 @@ export async function main(nodeProcess) {
throw err;
}
// must import esm
markedConfig = await import('file:///' + configFile);
markedConfig = await import(pathToFileURL(configFile).href);
}
if (markedConfig.default) {
+5
View File
@@ -91,6 +91,11 @@ describe('bin/marked', () => {
stdout: '<p>line1<br>line2</p>',
}));
it('config path with hash', testInput({
args: ['--config', fixturePath('bin-config#hash.js'), '-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 {
breaks: true,
};