simplify indent code

This commit is contained in:
Spencer Alger
2015-01-11 16:03:23 -07:00
parent 5eabe97420
commit c89f76342a

View File

@ -207,24 +207,24 @@ function logImportant(text) {
log('------------'); log('------------');
} }
function indent() { var RE = /(\r?\n)/g;
var RE = /\n/g;
var first = true; function push(m) {
return through2( return function () {
function (chunk, enc, cb) { var args = _.toArray(arguments);
if (first) { var cb = args.pop();
this.push(' '); this.push(m.apply(this, args));
first = false; cb();
};
} }
this.push(('' + chunk).replace(RE, '\n ')); function indent() {
cb(); var str = through2(
}, push(function (chunk) { return String(chunk).replace(RE, '$1 '); }),
function (cb) { push(function () { return '\n'; })
this.push('\n');
cb();
}
); );
str.push(' ');
return str;
} }
function task(name, def, fn) { function task(name, def, fn) {