summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-04-28 20:29:36 +0200
committerSamy Pessé <samypesse@gmail.com>2014-04-28 20:29:36 +0200
commit23056fc85da957d6f63808e59e13d8bd646a215d (patch)
tree022bdc72e87ef34677951b6743df291522661899 /bin
parent5f1bfc02805e074ab47bc8966410cf8042363c48 (diff)
downloadgitbook-23056fc85da957d6f63808e59e13d8bd646a215d.zip
gitbook-23056fc85da957d6f63808e59e13d8bd646a215d.tar.gz
gitbook-23056fc85da957d6f63808e59e13d8bd646a215d.tar.bz2
Use a global configuration file for a book (default to book.json)
Diffstat (limited to 'bin')
-rw-r--r--bin/build.js11
-rw-r--r--bin/utils.js42
2 files changed, 44 insertions, 9 deletions
diff --git a/bin/build.js b/bin/build.js
index 597b0de..36ffcbe 100644
--- a/bin/build.js
+++ b/bin/build.js
@@ -15,7 +15,7 @@ var buildCommand = function(command) {
.option('-t, --title <name>', 'Name of the book to generate, default is extracted from readme')
.option('-i, --intro <intro>', 'Description of the book to generate, default is extracted from readme')
.option('--plugins <plugins>', 'List of plugins to use separated by ","')
- .option('--pluginsConfig <json file>', 'JSON File containing plugins configuration')
+ .option('--config <config file>', 'Configuration file to use, defualt to book.json')
.option('-g, --github <repo_path>', 'ID of github repo like : username/repo')
.option('--githubHost <url>', 'The url of the github host (defaults to https://github.com/');
};
@@ -26,13 +26,6 @@ var makeBuildFunc = function(converter) {
dir = dir || process.cwd();
outputDir = options.output;
- // Read plugins config
- var pluginsConfig = {};
- if (options.pluginsConfig) {
- pluginsConfig = JSON.parse(fs.readFileSync(options.pluginsConfig))
- }
-
-
console.log('Starting build ...');
return converter(
_.extend({}, options || {}, {
@@ -44,7 +37,7 @@ var makeBuildFunc = function(converter) {
githubHost: options.githubHost,
generator: options.format,
plugins: options.plugins,
- pluginsConfig: pluginsConfig
+ configFile: options.config
})
)
.then(function(output) {
diff --git a/bin/utils.js b/bin/utils.js
new file mode 100644
index 0000000..b43936f
--- /dev/null
+++ b/bin/utils.js
@@ -0,0 +1,42 @@
+var Q = require('q');
+var _ = require('lodash');
+
+var http = require('http');
+var send = require('send');
+
+var path = require('path');
+var Gaze = require('gaze').Gaze;
+
+function watch(dir) {
+ var d = Q.defer();
+ dir = path.resolve(dir);
+
+ var gaze = new Gaze("**/*.md", {
+ cwd: dir
+ });
+
+ gaze.once("all", function(e, filepath) {
+ gaze.close();
+
+ d.resolve(filepath);
+ });
+ gaze.once("error", function(err) {
+ gaze.close();
+
+ d.reject(err);
+ });
+
+ return d.promise;
+}
+
+function logError(err) {
+ console.log(err.stack || err.message || err);
+ return Q.reject(err);
+};
+
+
+// Exports
+module.exports = {
+ watch: watch,
+ logError: logError
+};