Replace glob with better fstream-ignore

It ignores according to .gitignore and other folders
This commit is contained in:
Aaron O'Mullan
2014-03-31 19:18:15 -07:00
parent 347ae52e67
commit 6bcd483351
2 changed files with 40 additions and 6 deletions
+39 -5
View File
@@ -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
View File
@@ -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"