epub-to-pdf-cli 1.0.5 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/bin/cli.js +33 -6
- package/package.json +8 -5
- package/scripts/prepublish.js +6 -0
package/README.md
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
# 📘 EPUB to PDF CLI – Convert EPUB files to PDF using Calibre.
|
|
2
7
|
|
|
3
8
|
A simple and reliable **EPUB → PDF converter** using **Calibre**.
|
|
4
9
|
Works as both a **CLI tool** and a **Node.js library**.
|
package/bin/cli.js
CHANGED
|
@@ -1,11 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
2
|
import { convertEpubToPdf } from '../src/index.js';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { resolve } from 'path';
|
|
5
|
+
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
|
|
8
|
+
// --help
|
|
9
|
+
if (args.includes('--help') || args.length === 0) {
|
|
10
|
+
console.log(`
|
|
11
|
+
epub2pdf <input.epub> [output.pdf]
|
|
4
12
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
Options:
|
|
14
|
+
--help Show help
|
|
15
|
+
--version Show version
|
|
16
|
+
`);
|
|
17
|
+
process.exit(0);
|
|
9
18
|
}
|
|
10
19
|
|
|
11
|
-
|
|
20
|
+
// --version
|
|
21
|
+
if (args.includes('--version')) {
|
|
22
|
+
const pkg = JSON.parse(
|
|
23
|
+
readFileSync(new URL('../package.json', import.meta.url))
|
|
24
|
+
);
|
|
25
|
+
console.log(pkg.version);
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Conversion
|
|
30
|
+
const input = args[0];
|
|
31
|
+
const output = args[1];
|
|
32
|
+
|
|
33
|
+
convertEpubToPdf(resolve(input), output)
|
|
34
|
+
.then(() => console.log('✅ Conversion completed'))
|
|
35
|
+
.catch(err => {
|
|
36
|
+
console.error('❌', err.message);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "epub-to-pdf-cli",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.9",
|
|
4
|
+
"description": "CLI tool to convert EPUB to PDF using Calibre. Works with npx and global install.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"epub2pdf": "./bin/cli.js"
|
|
@@ -15,11 +15,14 @@
|
|
|
15
15
|
],
|
|
16
16
|
"keywords": [
|
|
17
17
|
"epub",
|
|
18
|
+
"epub-to-pdf",
|
|
18
19
|
"pdf",
|
|
19
|
-
"converter",
|
|
20
|
-
"calibre",
|
|
21
20
|
"ebook",
|
|
22
|
-
"
|
|
21
|
+
"ebook-converter",
|
|
22
|
+
"calibre",
|
|
23
|
+
"ebook-convert",
|
|
24
|
+
"cli",
|
|
25
|
+
"npx"
|
|
23
26
|
],
|
|
24
27
|
"author": "Suraj Sutar",
|
|
25
28
|
"license": "MIT",
|
package/scripts/prepublish.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { execSync } from 'child_process';
|
|
2
2
|
|
|
3
|
+
if (process.env.CI === 'true') {
|
|
4
|
+
console.log('⚠️ Skipping Calibre check in CI');
|
|
5
|
+
process.exit(0);
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
try {
|
|
4
9
|
execSync('ebook-convert --version', { stdio: 'ignore' });
|
|
10
|
+
console.log('✅ Calibre found');
|
|
5
11
|
} catch {
|
|
6
12
|
console.error(`
|
|
7
13
|
❌ Calibre is required but not installed.
|