summaryrefslogtreecommitdiffstats
path: root/lib/generate/index.js
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@friendco.de>2014-03-31 19:18:15 -0700
committerAaron O'Mullan <aaron.omullan@friendco.de>2014-03-31 19:19:52 -0700
commit6bcd483351dc0fa45a0a8ad88405b27ff8b118f0 (patch)
treee41ff924798a4b6a3b0ec2efa3137a1aa1ad7826 /lib/generate/index.js
parent347ae52e677887413b2e68d6e3d4217b92fc88ee (diff)
downloadgitbook-6bcd483351dc0fa45a0a8ad88405b27ff8b118f0.zip
gitbook-6bcd483351dc0fa45a0a8ad88405b27ff8b118f0.tar.gz
gitbook-6bcd483351dc0fa45a0a8ad88405b27ff8b118f0.tar.bz2
Replace glob with better fstream-ignore
It ignores according to .gitignore and other folders
Diffstat (limited to 'lib/generate/index.js')
-rw-r--r--lib/generate/index.js44
1 files changed, 39 insertions, 5 deletions
diff --git a/lib/generate/index.js b/lib/generate/index.js
index a06aa8b..4b81d8f 100644
--- a/lib/generate/index.js
+++ b/lib/generate/index.js
@@ -1,11 +1,48 @@
var Q = require("q");
var _ = require("lodash");
+
var path = require("path");
-var glob = require("glob");
+var Ignore = require("fstream-ignore");
+
var fs = require("./fs");
var parse = require("../parse");
var template = require("./template");
+
+
+function getFiles(path) {
+ var d = Q.defer();
+
+ // Our list of files
+ var files = [];
+
+ var ig = Ignore({
+ path: path,
+ ignoreFiles: ['.ignore', '.gitignore']
+ });
+
+ // Add extra rules to ignore common folders
+ ig.addIgnoreRules([
+ '.git/'
+ ], '__custom_stuff');
+
+ // Push each file to our list
+ ig.on('child', function (c) {
+ files.push(
+ c.path.substr(c.root.path.length + 1) + (c.props.Directory === true ? '/' : '')
+ );
+ });
+
+ ig.on('end', function() {
+ d.resolve(files);
+ });
+
+ ig.on('error', d.reject);
+
+ return d.promise;
+}
+
+
var generate = function(root, output, options) {
var files, summary, navigation, tpl;
@@ -29,10 +66,7 @@ var generate = function(root, output, options) {
// List all files in the repository
.then(function() {
- return Q.nfcall(glob, "**/*", {
- cwd: root,
- mark: true
- });
+ return getFiles(root);
})
// Check repository is valid