Skip to content

Commit

Permalink
Add generator option to exclude files
Browse files Browse the repository at this point in the history
exclude argument takes a comma separated string of filepath globs (minimatch style)
  • Loading branch information
John Hunter committed Oct 7, 2015
1 parent e98c5f4 commit 1816f93
Show file tree
Hide file tree
Showing 25 changed files with 2,110 additions and 3 deletions.
22 changes: 19 additions & 3 deletions js/backend/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
mime = require('mime'),
mysql = require('mysql'),
nomnom = require('nomnom'),
minimatch = require('minimatch'),
esprima = require('../lib/esprima.js'),
config = require('../config.json'),
debug = !!config.debug,
Expand All @@ -28,7 +29,12 @@
abbr: 'v',
help: 'Print message and errors.',
flag: true
}
},
'exclude': {
abbr: 'x',
help: 'List of file patterns to exclude (comma separated)',
default: ''
}
});

consoleArguments = nomnom.parse();
Expand All @@ -37,6 +43,9 @@
if(!consoleArguments.city || consoleArguments.city=='') {
consoleArguments.city = path.basename(consoleArguments.project);
}

var excludes = consoleArguments.exclude.split(',');

//console.log(consoleArguments);
//process.exit();
fs.exists(consoleArguments.project, function(exists) {
Expand Down Expand Up @@ -148,7 +157,7 @@
Waiting.up();
fs.stat(currentPath, function defineType(error, stats) {
if(error) {
console.log('Invalid paht: ' + currentPath);
console.log('Invalid path: ' + currentPath);
Waiting.end();
} else if(stats.isDirectory()) {
if(consoleArguments.verbose) {
Expand All @@ -168,7 +177,14 @@
});
} else {
var type = mime.lookup(currentPath), validos = ['text/javascript', 'application/javascript'];
if(validos.indexOf(type)<0) {
var excluded = false;
excludes.forEach(function(exclude){
if (minimatch(currentPath, exclude)) {
excluded = true;
}
});

if(excluded || validos.indexOf(type)<0) {
currentPath = path.relative(consoleArguments.project, currentPath);
if(consoleArguments.verbose) {
console.log('Ignoring file: ' + currentPath);
Expand Down
15 changes: 15 additions & 0 deletions js/node_modules/minimatch/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

216 changes: 216 additions & 0 deletions js/node_modules/minimatch/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1816f93

Please sign in to comment.