Permalink
Browse files

Adding support for -x to exclude a build during a --walk

  • Loading branch information...
1 parent 0d62887 commit d6b78f2cfd8bf557501c9383009c8eeb5f8a3ad9 @davglass davglass committed Apr 16, 2013
Showing with 27 additions and 14 deletions.
  1. +3 −1 lib/args.js
  2. +1 −0 lib/pack.js
  3. +1 −0 lib/tasks.js
  4. +22 −13 lib/walk.js
View
@@ -10,6 +10,7 @@ var nopt = require('nopt'),
'coverage': Boolean,
'csslint': Boolean,
'cssproc': String,
+ 'excludes': Array,
'exec': Boolean,
'fail': Boolean,
'global-config': Boolean,
@@ -38,7 +39,8 @@ var nopt = require('nopt'),
"m" : ["--modules"],
"mods" : ["--modules"],
"v" : ["--version"],
- "w": ["--walk"]
+ "w": ["--walk"],
+ "x": ["--excludes"]
};
var raw = function (args) {
View
@@ -18,6 +18,7 @@ exports.valid = function (json) {
return !(json[exports.bad]);
};
+/*jshint forin: false */
var flatten = function (json) {
var walker = function (i) {
return function (l) {
View
@@ -8,6 +8,7 @@ var fs = require('fs'),
var files = fs.readdirSync(path.join(__dirname, './tasks/'));
+/*jshint forin: false */
files.forEach(function (file) {
if (path.extname(file) === '.js') {
var mod = require('./tasks/' + file), name;
View
@@ -22,13 +22,20 @@ exports.run = function (options, callback) {
var modStack = new Stack(),
start = new Date(),
mods = [],
+ excludes = {},
max = options.max || false,
bar,
ProgressBar,
i,
args = [],
checkDirectory;
+ if (options.excludes && options.excludes.length) {
+ options.excludes.forEach(function(mod) {
+ excludes[mod] = mod;
+ });
+ }
+
if (options.progress) {
ProgressBar = require('progress'),
bar = new ProgressBar(log.color(' shifting [', 'magenta') +
@@ -98,20 +105,22 @@ exports.run = function (options, callback) {
fs.readdir(workingdir, modStack.add(function (err, dirs) {
dirs.forEach(function (mod) {
var p = path.join(workingdir, mod);
- exists(path.join(p, 'build.json'), modStack.add(function (yes) {
- var relative, stat;
- if (yes) {
- if (!options.modules || has(options.modules, mod)) {
- relative = workingdir.replace(startdir, '');
- mods.push(path.join(relative, mod));
+ if (!excludes[mod]) {
+ exists(path.join(p, 'build.json'), modStack.add(function (yes) {
+ var relative, stat;
+ if (yes) {
+ if (!options.modules || has(options.modules, mod)) {
+ relative = workingdir.replace(startdir, '');
+ mods.push(path.join(relative, mod));
+ }
+ } else if (options.recursive) {
+ stat = fs.statSync(p);
+ if (stat.isDirectory()) {
+ checkDirectory(startdir, p);
+ }
}
- } else if (options.recursive) {
- stat = fs.statSync(p);
- if (stat.isDirectory()) {
- checkDirectory(startdir, p);
- }
- }
- }));
+ }));
+ }
});
}));
};

0 comments on commit d6b78f2

Please sign in to comment.