summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/book.js2
-rw-r--r--lib/template.js4
-rw-r--r--lib/utils/string.js5
-rw-r--r--lib/utils/watch.js15
4 files changed, 11 insertions, 15 deletions
diff --git a/lib/book.js b/lib/book.js
index 8b0d22b..e61d771 100644
--- a/lib/book.js
+++ b/lib/book.js
@@ -115,7 +115,7 @@ Book.prototype.parse = function() {
return that.parseLangs()
.then(function() {
multilingual = that.langs.length > 0;
- if (multilingual) that.log.info.ln("Parsing multilingual book, with", that.langs.length, "lanuages");
+ if (multilingual) that.log.info.ln("Parsing multilingual book, with", that.langs.length, "languages");
// Sub-books that inherit from the current book configuration
that.books = _.map(that.langs, function(lang) {
diff --git a/lib/template.js b/lib/template.js
index 187df87..3e6364d 100644
--- a/lib/template.js
+++ b/lib/template.js
@@ -2,9 +2,9 @@ var _ = require("lodash");
var Q = require("q");
var path = require("path");
var nunjucks = require("nunjucks");
+var escapeStringRegexp = require("escape-string-regexp");
var git = require("./utils/git");
-var stringUtils = require("./utils/string");
var fs = require("./utils/fs");
var batch = require("./utils/batch");
var pkg = require("../package.json");
@@ -302,7 +302,7 @@ TemplateEngine.prototype.addBlock = function(name, block) {
TemplateEngine.prototype._applyShortcut = function(parser, content, shortcut) {
if (!_.contains(shortcut.parsers, parser)) return content;
var regex = new RegExp(
- stringUtils.escapeRegex(shortcut.start) + "([\\s\\S]*?[^\\$])" + stringUtils.escapeRegex(shortcut.end),
+ escapeStringRegexp(shortcut.start) + "([\\s\\S]*?[^\\$])" + escapeStringRegexp(shortcut.end),
'g'
);
return content.replace(regex, function(all, match) {
diff --git a/lib/utils/string.js b/lib/utils/string.js
index 588f4d9..72a9ca0 100644
--- a/lib/utils/string.js
+++ b/lib/utils/string.js
@@ -20,12 +20,7 @@ function optionsToShellArgs(options) {
.join(" ");
}
-function escapeRegex(str) {
- return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
-}
-
module.exports = {
- escapeRegex: escapeRegex,
escapeShellArg: escapeShellArg,
optionsToShellArgs: optionsToShellArgs,
toLowerCase: String.prototype.toLowerCase.call.bind(String.prototype.toLowerCase)
diff --git a/lib/utils/watch.js b/lib/utils/watch.js
index 795bbb7..b6e18e7 100644
--- a/lib/utils/watch.js
+++ b/lib/utils/watch.js
@@ -1,7 +1,7 @@
var Q = require('q');
var _ = require('lodash');
var path = require('path');
-var Gaze = require('gaze').Gaze;
+var chokidar = require('chokidar');
var parsers = require('gitbook-parsers')
@@ -17,17 +17,18 @@ function watch(dir) {
toWatch.push("**/*"+ext);
});
- var gaze = new Gaze(toWatch, {
- cwd: dir
+ var watcher = chokidar.watch(toWatch, {
+ cwd: dir,
+ ignoreInitial: true
});
- gaze.once("all", function(e, filepath) {
- gaze.close();
+ watcher.once("all", function(e, filepath) {
+ watcher.close();
d.resolve(filepath);
});
- gaze.once("error", function(err) {
- gaze.close();
+ watcher.once("error", function(err) {
+ watcher.close();
d.reject(err);
});