Skip to content

Commit ab2977a

Browse files
authored
fix: fix cli (#2294)
1 parent 6cba7b4 commit ab2977a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

bin/marked.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ async function help() {
2727
const { dirname, resolve } = await import('path');
2828
const { fileURLToPath } = await import('url');
2929
const __dirname = dirname(fileURLToPath(import.meta.url));
30-
spawn('man', [resolve(__dirname, '../man/marked.1')], options)
31-
.on('error', async() => {
32-
console.log(await readFile(resolve(__dirname, '../man/marked.1.txt'), 'utf8'));
33-
});
30+
const helpText = await readFile(resolve(__dirname, '../man/marked.1.txt'), 'utf8');
31+
32+
// eslint-disable-next-line promise/param-names
33+
await new Promise(res => {
34+
spawn('man', [resolve(__dirname, '../man/marked.1')], options)
35+
.on('error', () => {
36+
console.log(helpText);
37+
})
38+
.on('close', res);
39+
});
3440
}
3541

3642
async function version() {
@@ -149,7 +155,7 @@ async function main(argv) {
149155
: marked(data, options);
150156

151157
if (output) {
152-
return await writeFile(output, data);
158+
return await writeFile(output, html);
153159
}
154160

155161
process.stdout.write(html + '\n');

0 commit comments

Comments
 (0)