mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-10-03 20:20:35 +00:00
Replace glob with better fstream-ignore
It ignores according to .gitignore and other folders
This commit is contained in:
+39
-5
@@ -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
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
"lodash": "2.4.1",
|
||||
"marked": "0.3.2",
|
||||
"swig": "1.3.2",
|
||||
"glob": "3.2.9",
|
||||
"fstream-ignore": "0.0.7",
|
||||
"q": "1.0.1",
|
||||
"commander": "2.2.0",
|
||||
"fs-extra": "0.8.1"
|
||||
|
||||
Reference in New Issue
Block a user