-
Notifications
You must be signed in to change notification settings - Fork 0
/
man.mjs
40 lines (34 loc) · 963 Bytes
/
man.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { rmSync } from 'fs';
import { dirname, resolve } from 'path';
import man2pdf from 'man2pdf';
process.chdir(dirname(new URL(import.meta.url).pathname));
{
// create PDF, no section names
man2pdf('man'); // creates man(1).pdf
man2pdf('man', 'man.pdf'); // creates man.pdf
man2pdf('man', '../out'); // creates ../out/man(1).pdf
// clean up
for (const pdfPath of [
'man(1).pdf',
'man.pdf',
'../out/man(1).pdf'
]) {
rmSync(pdfPath);
console.log('Removed:', resolve(pdfPath));
}
}
{
// create PDF, with section names
man2pdf('1 man'); // creates man(1).pdf
man2pdf('1 man', 'man.pdf'); // creates man.pdf
man2pdf('1 man', '../out'); // creates ../out/man(1).pdf
// clean up
for (const pdfPath of [
'man(1).pdf',
'man.pdf',
'../out/man(1).pdf'
]) {
rmSync(pdfPath);
console.log('Removed:', resolve(pdfPath));
}
}