
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
node-calibre
Advanced tools
A simple Node wrapper for Calibre's command line tools.
Built and maintained by the Xyfir Network.
node-calibre is mostly a simple wrapper around Calibre's CLI using Node's child_process.exec(), without many extra features added. In the future this package will contain more methods unique to each of Calibre's binaries and with both better error checking and improved results provided on success.
import { Calibre } from 'node-calibre';
// Create Calibre instance
const calibre = new Calibre({ library: '/path/to/calibre/library' });
// Convert ebook from pdf to epub
const newFile = await calibre.ebookConvert('/path/to/book.pdf', 'epub', {
epubFlatten: null
});
console.log(newFile); // "/path/to/book.pdf.epub"
let result: string;
// Add book to Calibre library
result = await calibre.run('calibredb add', ['/path/to/book.epub']);
console.log(result); // "Added book ids: ..."
// List books in Calibre Library
result = await calibre.run('calibredb list', [], { limit: 10 });
console.log(result); // first 10 books
// You can optionally pass `options` as the second parameter
// `forMachine: null` gets converted to `--for-machine`
result = await calibre.run('calibredb list', {
limit: 10,
forMachine: null
});
console.log(Array.isArray(JSON.parse(result))); // true
constructor(options)
options.library
: string - optional, default ''
calibredb
commands.--library-path
option for calibredb
commands.options.log
: boolean - optional, default false
options.execOptions
: object - optional, default {maxBuffer: 2048000}
child_process.exec()
as the options argument.run(command[, args][, options])
Runs a command on one of Calibre's binaries (calibredb, ebook-convert, etc). Find all here.
command
: string
args
: any[] - optional, default []
""
, and escaped.options
: object - optional, default {}
""
and escaped.{'some-option': null}
.{forMachine: null}
-> --for-machine
.--field
in calibredb set_metadata
), you can pass an array with all of the values: {field: ['tags:tag1,tag2', 'title:Some New Title']}
-> --field "tags:tag1,tag2" --field "title:Some New Title"
.A promise that is rejected if the callback of Node's child_process.exec() has a value for error or stderr and resolves to the callback's stdout if no error occurred. Due to how Calibre's command line tools work, most of the time the promise should resolve regardless of whether Calibre encountered an issue. It's up to you to check the resolved result to determine if the command was successful.
ebookConvert(input, format, options)
Wrapper for ebook-convert.
input
: string
format
: string
input
to.options
: object
ebook-convert
command.Full path to the new file.
exec(command[, options])
This method should only be used if for some reason you need to build your own command string. It's essentially just a Promise-wrapped child_process.exec()
that gets passed the execOptions
from the constructor.
command
: string
calibredb list --for-machine --limit 10
.options
: object
execOptions
object that was passed to the constructor.execOptions
.Same as run()
, which builds a command string and passes it to exec()
.
maxBuffer
property of the options object accepted by Node's child_process.exec()
. It limits the size of output that can be received from a process, in this case one of Calibre's binaries. Unless you set maxBuffer
as a property in the execOptions
object, the maximum buffer size will be increased from the default of 200KB to 2MB. The vast majority of commands will get nowhere near this number, however certain commands like calibredb list
with all fields requested on a large library can get close or even surpass that limit in certain cases. If a command's output exceeds the maxBuffer limit, an error will be thrown.args
array and options
object of run()
, but not as a command or an option name. In other words, args and option values are are wrapped in double quotes and escaped.cwd
property of execOptions
(see constructor options) to set Calibre's bin directory.[2.1.1] - 2019-05-16
FAQs
A wrapper for Calibre's command line tools.
We found that node-calibre demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.