epub-to-pdf-cli 1.0.6 → 1.0.10

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/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
- const input = process.argv[2];
6
- if (!input) {
7
- console.error('Usage: epub2pdf <file.epub>');
8
- process.exit(1);
13
+ Options:
14
+ --help Show help
15
+ --version Show version
16
+ `);
17
+ process.exit(0);
9
18
  }
10
19
 
11
- convertEpubToPdf(input);
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,6 +1,6 @@
1
1
  {
2
2
  "name": "epub-to-pdf-cli",
3
- "version": "1.0.6",
3
+ "version": "1.0.10",
4
4
  "description": "CLI tool to convert EPUB to PDF using Calibre. Works with npx and global install.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -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.