Skip to content

Commit

Permalink
resolveAssetConfig: Replace seq with async.
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed May 13, 2016
1 parent ffaa2c5 commit 936efcf
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var util = require('util'),
childProcess = require('child_process'),
_ = require('lodash'),
EventEmitter = require('events').EventEmitter,
seq = require('seq'),
async = require('async'),
Path = require('path'),
passError = require('passerror'),
urlTools = require('urltools'),
Expand Down Expand Up @@ -433,26 +433,20 @@ _.extend(AssetGraph.prototype, {
var that = this;
if (_.isArray(assetConfig)) {
// Call ourselves recursively for each item, flatten the results and report back
if (assetConfig.some(_.isArray)) {
if (assetConfig.some(Array.isArray)) {
throw new Error('AssetGraph.resolveAssetConfig: Multidimensional array not supported.');
}
return seq(assetConfig)
.parMap(function (_assetConfig) {
var callback = this;
that.resolveAssetConfig(_assetConfig, fromUrl, function (err, _resolvedAssetConfigs) {
if (err) {
that.emit('warn', err);
return callback(null, []);
} else {
callback(null, _resolvedAssetConfigs);
}
});
})
.unflatten()
.seq(function (resolvedAssetConfigs) {
cb(null, _.flatten(resolvedAssetConfigs));
})
.catch(cb);
return async.map(assetConfig, function (assetConfig, cb) {
that.resolveAssetConfig(assetConfig, fromUrl, function (err, resolvedAssetConfigs) {
if (err) {
that.emit('warn', err);
return cb(null, []);
}
cb(null, resolvedAssetConfigs);
});
}, passError(cb, function (resolvedAssetConfigs) {
cb(null, _.flatten(resolvedAssetConfigs));
}));
}
if (typeof assetConfig === 'string') {
if (/^[\w\+]+:/.test(assetConfig)) {
Expand Down

0 comments on commit 936efcf

Please sign in to comment.