refactor: use loash when possible (#7230)

This commit is contained in:
Peter Jaszkowiak
2019-01-12 12:28:53 -07:00
committed by Barış Soner Uşaklı
parent a4ab13d323
commit e1ca2d81f9
4 changed files with 31 additions and 50 deletions

View File

@@ -167,19 +167,14 @@ function build(targets, options, callback) {
return aliases[target];
})
// filter nonexistent targets
.filter(Boolean)
// map multitargets to their sets
.reduce(function (prev, target) {
if (Array.isArray(targetHandlers[target])) {
return prev.concat(targetHandlers[target]);
}
.filter(Boolean);
return prev.concat(target);
}, [])
// unique
.filter(function (target, i, arr) {
return arr.indexOf(target) === i;
});
// map multitargets to their sets
targets = _.uniq(_.flatMap(targets, target => (
Array.isArray(targetHandlers[target]) ?
targetHandlers[target] :
target
)));
winston.verbose('[build] building the following targets: ' + targets.join(', '));