Skip to content

Commit

Permalink
Fixes #34 - Added --clean and defaulted it to false
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Oct 29, 2012
1 parent b1abc77 commit 1622728
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/args.js
Expand Up @@ -21,6 +21,7 @@ var nopt = require('nopt'),
cache: Boolean,
jsstamp: Boolean,
list: Boolean,
clean: Boolean,
config: require('path'),
lint: [ 'config', false ],
csslint: Boolean,
Expand Down Expand Up @@ -79,6 +80,7 @@ var setDefaults = function(parsed) {
parsed.istanbul = (parsed.istanbul === undefined || parsed.istanbul === false) ? false : true;
parsed.quiet = (parsed.quiet === undefined || parsed.quiet === false) ? false : true;
parsed.silent = (parsed.silent === undefined || parsed.silent === false) ? false : true;
parsed.clean = (parsed.clean === undefined || parsed.clean === false) ? false : true;
parsed['lint-stderr'] = (parsed['lint-stderr'] === undefined || parsed['lint-stderr'] === false) ? false : true;
parsed.progress = (parsed.progress === undefined || parsed.progress === false) ? false : true;
return parsed;
Expand Down
1 change: 1 addition & 0 deletions lib/help.js
Expand Up @@ -69,6 +69,7 @@ if (args.help) {
console.log('Experimental Options:');
console.log(' --semi Toggle on the strict semicolon checking in Uglify');
console.log(' --cache/--no-cache Cache the results of the build and bail if building for no reason, defaults to --no-cache');
console.log(' --clean Remove the build directory before building (to clean old files)');
console.log(' --compressor Use YUI Compressor instead of uglify');
console.log(' --fail Fail the build if lint fails');
console.log(' --no-lint Skip JSlint, you better know what you are doing!');
Expand Down
17 changes: 13 additions & 4 deletions lib/module.js
Expand Up @@ -611,7 +611,7 @@ var setReplacers = function (options) {
};

var build = function (mod, name, options, callback) {
var stack = new Stack();
var stack = new Stack(), _build;

if (options.lint === false) {
defaultLint = options.lint;
Expand All @@ -637,8 +637,7 @@ var build = function (mod, name, options, callback) {
lintSTDError = options['lint-stderr'];
mod.stamp = options.jsstamp;

log.info('deleting build dir: ' + path.join(buildDir, name || mod.name));
rimraf(path.join(buildDir, name || mod.name), stack.add(function() {
_build = stack.add(function() {
if (mod.jsfiles) {
exports.js(mod, name, stack.add(function (err) {
if (err) {
Expand Down Expand Up @@ -667,7 +666,17 @@ var build = function (mod, name, options, callback) {
if (mod.copy) {
exports.copy(mod, name, stack.add(noop));
}
}));
});

if (options.clean) {
log.info('deleting build dir: ' + path.join(buildDir, name || mod.name));
rimraf(path.join(buildDir, name || mod.name), _build);
} else {
_build();
}




stack.done(function () {
if (!stack.complete) {
Expand Down
1 change: 1 addition & 0 deletions tests/args.js
Expand Up @@ -24,6 +24,7 @@ var argsTests = {
'--progress': 'progress',
'--csslint': 'csslint',
'--coverage': 'coverage',
'--clean': 'clean',
'--lint-stderr': 'lint-stderr',
'-w': 'walk'
};
Expand Down

0 comments on commit 1622728

Please sign in to comment.