mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix(cli): use file URL for config import (#3923)
This commit is contained in:
+2
-1
@@ -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) {
|
||||
|
||||
@@ -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')}'`,
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export default {
|
||||
breaks: true,
|
||||
};
|
||||
Reference in New Issue
Block a user