Add --jobs option for the convert command

This doesn't seem that helpful as there seems to be a lot of sequential work going on regardless.
This commit is contained in:
Domenic Denicola 2019-08-16 23:37:00 -04:00
commit 4386d48021
2 changed files with 10 additions and 3 deletions

View file

@ -6,12 +6,12 @@ const serializeToXML = require("xmlserializer").serializeToString;
const { JSDOM } = require("jsdom");
const substitutions = require("./substitutions.json");
module.exports = async (cachePath, manifestPath, contentPath) => {
module.exports = async (cachePath, manifestPath, contentPath, concurrentJobs) => {
const manifestContents = await fs.readFile(manifestPath, { encoding: "utf-8" });
const chapters = JSON.parse(manifestContents);
console.log("All chapters downloaded; beginning conversion to EPUB chapters");
const mapper = throat(10, chapter => convertChapter(chapter, cachePath, contentPath));
const mapper = throat(concurrentJobs, chapter => convertChapter(chapter, cachePath, contentPath));
await Promise.all(chapters.map(mapper));
console.log("All chapters converted");