If you use this project, you can click star to support it.
Provide an API to get the calibre tool
This library is used to get the following tools:
get-calibre-tools
will search for calibre on your computer.
/Applications/calibre.app/Contents/console.app/Contents/MacOS/
directory./usr/bin/
directoryC:\Program Files (x86)\Calibre2\
directory. If not, it will also look up the registry field: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\
If not, you will get an error and prompt you to set the path manually using the setPath method.
const getCalibreTools = require('get-calibre-tools');
getCalibreTools('ebook-meta')
.catch(e => {
console.log(e);
})
.then(path => {
console.log(path) // => file path
})
const getCalibreTools = require('get-calibre-tools');
getCalibreTools('ebook-meta')
.catch(e => {
console.log(e); // => [get-calibre-tools]: Did not find ebook-meta(.exe) file. Please use the setPath method to manually specify the path.
})
.then(path => {
})
setPath
method to manually specify the pathThe set path will be written to the local file for later value.
getCalibreTools.setPath(`D:\\Program Files\\Calibre2\\ebook-meta.exe`)
.catch(e => {
console.log(e);
})
.then(path => {
console.log(path)
});
Clear the configuration file when the path in the configuration file has changed
getCalibreTools.clearConfig()
.catch(e => {
console.log(e);
})
.then(() => {
console.log('success');
})
$ cat ~/.calibre-node/calibrePath.txt
calibredb=/Applications/calibre.app/Contents/console.app/Contents/MacOS/calibredb
ebook-meta=/Applications/calibre.app/Contents/console.app/Contents/MacOS/ebook-meta
ebook-edit=/Applications/calibre.app/Contents/console.app/Contents/MacOS/ebook-edit
getCalibreTools.clearConfig('ebook-meta')
.catch(e => {
console.log(e);
})
.then(() => {
console.log('success');
});
$ cat ~/.calibre-node/calibrePath.txt
calibredb=/Applications/calibre.app/Contents/console.app/Contents/MacOS/calibredb
ebook-edit=/Applications/calibre.app/Contents/console.app/Contents/MacOS/ebook-edit