From 23e79ed6ba9a533acd403e97e1825e297ffe5e9b Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Thu, 21 May 2015 00:58:43 -0400 Subject: [PATCH] Move copying of scaffolding files into scaffold.js --- lib/scaffold.js | 19 ++++++++++++------- lib/worm-scraper.js | 9 +++------ scaffolding/{ => META-INF}/container.xml | 0 3 files changed, 15 insertions(+), 13 deletions(-) rename scaffolding/{ => META-INF}/container.xml (100%) diff --git a/lib/scaffold.js b/lib/scaffold.js index 9d06e9d..b0ca12f 100644 --- a/lib/scaffold.js +++ b/lib/scaffold.js @@ -1,6 +1,7 @@ "use strict"; const fs = require("mz/fs"); const path = require("path"); +const cpr = require("thenify")(require("cpr")); const BOOK_TITLE = "Worm"; const BOOK_AUTHOR = "wildbow"; @@ -8,13 +9,17 @@ const BOOK_ID = "urn:uuid:e7f3532d-8db6-4888-be80-1976166b7059"; const NCX_FILENAME = "toc.ncx"; -module.exports = function (contentPath, chaptersPath, manifestPath) { - return getChapters(contentPath, chaptersPath, manifestPath).then(function (chapters) { - return Promise.all([ - writeOpf(chapters, contentPath), - writeNcx(chapters, contentPath) - ]); - }); +module.exports = function (scaffoldingPath, bookPath, contentPath, chaptersPath, manifestPath) { + return Promise.all([ + cpr(scaffoldingPath, bookPath), + getChapters(contentPath, chaptersPath, manifestPath).then(function (chapters) { + return Promise.all([ + writeOpf(chapters, contentPath), + writeNcx(chapters, contentPath) + ]); + }) + ]) + .then(function () { }); }; function writeOpf(chapters, contentPath) { diff --git a/lib/worm-scraper.js b/lib/worm-scraper.js index 5bc1785..8a3d901 100644 --- a/lib/worm-scraper.js +++ b/lib/worm-scraper.js @@ -3,7 +3,6 @@ const path = require("path"); const mkdirp = require("mkdirp-then"); const rimraf = require("rimraf-then"); const yargs = require("yargs"); -const cpr = require("thenify")(require("cpr")); const packageJson = require("../package.json"); const download = require("./download.js"); @@ -53,8 +52,8 @@ const cachePath = path.resolve(argv.cacheDirectory); const manifestPath = path.resolve(cachePath, "manifest.json"); const scaffoldingPath = path.resolve(__dirname, "../scaffolding"); -const outPath = path.resolve(argv.bookDirectory); -const contentPath = path.resolve(outPath, "OEBPS"); +const bookPath = path.resolve(argv.bookDirectory); +const contentPath = path.resolve(bookPath, "OEBPS"); const chaptersPath = path.resolve(contentPath, "chapters"); const commands = []; @@ -78,9 +77,7 @@ if (argv._.indexOf("convert") !== -1) { if (argv._.indexOf("scaffold") !== -1) { commands.push(function () { - return cpr(scaffoldingPath, outPath).then(function () { - return scaffold(contentPath, chaptersPath, manifestPath); - }); + return scaffold(scaffoldingPath, bookPath, contentPath, chaptersPath, manifestPath); }); } diff --git a/scaffolding/container.xml b/scaffolding/META-INF/container.xml similarity index 100% rename from scaffolding/container.xml rename to scaffolding/META-INF/container.xml