summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2015-07-31 15:08:56 +0200
committerAaron O'Mullan <aaron.omullan@gmail.com>2015-07-31 15:08:56 +0200
commitd699dff872a36b33719385ddf8b641afdc5bada1 (patch)
tree46ee428353dd09a94fdf60c03d219d4fb24ee31e
parent501843d6243e0be3bcab0e7c9cc1b6ff2886d4f4 (diff)
downloadgitbook-d699dff872a36b33719385ddf8b641afdc5bada1.zip
gitbook-d699dff872a36b33719385ddf8b641afdc5bada1.tar.gz
gitbook-d699dff872a36b33719385ddf8b641afdc5bada1.tar.bz2
Use Book.resolve when possible
For added consistency
-rw-r--r--lib/configuration.js4
-rw-r--r--lib/generator.js6
-rw-r--r--lib/generators/website.js2
-rw-r--r--lib/template.js2
4 files changed, 7 insertions, 7 deletions
diff --git a/lib/configuration.js b/lib/configuration.js
index 9e839e6..254367b 100644
--- a/lib/configuration.js
+++ b/lib/configuration.js
@@ -100,7 +100,7 @@ Configuration.prototype.load = function() {
try {
configPath = require.resolve(
- path.resolve(that.book.root, that.options.configFile)
+ that.book.resolve(that.options.configFile)
);
// Invalidate node.js cache for livreloading
@@ -125,7 +125,7 @@ Configuration.prototype.load = function() {
that.book.log.warn.ln("you should specify a gitbook version to use in your book.json, for example: "+(_.first(pkg.version.split("."))+".x.x"));
}
- that.options.output = path.resolve(that.options.output || path.join(that.book.root, "_book"));
+ that.options.output = path.resolve(that.options.output || that.book.resolve("_book"));
that.options.plugins = normalizePluginsList(that.options.plugins);
that.options.defaultsPlugins = normalizePluginsList(that.options.defaultsPlugins || "");
that.options.plugins = _.union(that.options.plugins, that.options.defaultsPlugins);
diff --git a/lib/generator.js b/lib/generator.js
index c809de2..407afa5 100644
--- a/lib/generator.js
+++ b/lib/generator.js
@@ -36,7 +36,7 @@ BaseGenerator.prototype.convertFile = function(input) {
// Copy file to the output (non parsable)
BaseGenerator.prototype.transferFile = function(input) {
return fs.copy(
- path.join(this.book.root, input),
+ this.book.resolve(input),
path.join(this.options.output, input)
);
};
@@ -53,8 +53,8 @@ BaseGenerator.prototype.copyCover = function() {
var that = this;
return Q.all([
- fs.copy(path.join(that.book.root, "cover.jpg"), path.join(that.options.output, "cover.jpg")),
- fs.copy(path.join(that.book.root, "cover_small.jpg"), path.join(that.options.output, "cover_small.jpg"))
+ fs.copy(that.book.resolve("cover.jpg"), path.join(that.options.output, "cover.jpg")),
+ fs.copy(that.book.resolve("cover_small.jpg"), path.join(that.options.output, "cover_small.jpg"))
])
.fail(function() {
// If orignaly from multi-lang, try copy from parent
diff --git a/lib/generators/website.js b/lib/generators/website.js
index de833d3..675092f 100644
--- a/lib/generators/website.js
+++ b/lib/generators/website.js
@@ -50,7 +50,7 @@ Generator.prototype.prepareStyles = function() {
this.styles = _.chain(this.styles)
.map(function(style) {
var stylePath = that.options.styles[style];
- if (stylePath && fs.existsSync(path.resolve(that.book.root, stylePath))) {
+ if (stylePath && fs.existsSync(that.book.resolve(stylePath))) {
return [style, stylePath];
}
return null;
diff --git a/lib/template.js b/lib/template.js
index bc3e53e..b31fab9 100644
--- a/lib/template.js
+++ b/lib/template.js
@@ -24,7 +24,7 @@ var BookLoader = nunjucks.Loader.extend({
git.resolveFile(fileurl)
.then(function(filepath) {
// Is local file
- if (!filepath) filepath = path.resolve(that.book.root, fileurl);
+ if (!filepath) filepath = that.book.resolve(fileurl);
else that.book.log.debug.ln("resolve from git", fileurl, "to", filepath)
// Read file from absolute path