Move copying of scaffolding files into scaffold.js

This commit is contained in:
Domenic Denicola 2015-05-21 00:58:43 -04:00
commit 23e79ed6ba
3 changed files with 15 additions and 13 deletions

View file

@ -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) {

View file

@ -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);
});
}