Skip to content

Commit

Permalink
[api] Add remote dependencies to roles
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalecki committed May 27, 2013
1 parent b02da72 commit 95efc48
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions lib/dependencies.js
Expand Up @@ -24,11 +24,17 @@ var path = require('path'),
// Creates a dependency tree for the specified `systems`.
//
var dependencies = module.exports = function (options, callback) {
var systems = options.systems,
client = options.client,
os = options.os,
all = options.all || {},
tree = {};
var systems = options.systems,
depsClient = options.dependenciesClient,
remoteDepsClient = options.remoteDependenciesClient || depsClient,
os = options.os,
all = options.all || {},
type = options.type || ['remoteDependencies', 'dependencies'],
tree = {};

if (!depsClient) {
depsClient = remoteDepsClient = options.client;
}

//
// Helper function which builds the subtree for
Expand All @@ -47,7 +53,7 @@ var dependencies = module.exports = function (options, callback) {
return next();
}

client.get(name, function (err, system) {
depsClient.get(name, function (err, system) {
if (err) {
return next(new Error('Error fetching ' + name + ': ' + err.message.replace(/Error /, '')));
}
Expand Down Expand Up @@ -97,20 +103,28 @@ var dependencies = module.exports = function (options, callback) {
}

async.parallel({
dependencies: async.apply(dependencies, {
systems: system.dependencies,
client: client,
all: all,
os: os
}),
dependencies: function deps(next) {
if (!system.dependencies || type.indexOf('dependencies') === -1) {
return next();
}

dependencies({
systems: system.dependencies,
client: depsClient,
all: all,
type: type,
os: os
}, next);
},
remoteDependencies: function remoteDeps(next) {
if (!system.remoteDependencies) {
if (!system.remoteDependencies || type.indexOf('remoteDependencies')) {
return next();
}

dependencies({
systems: system.remoteDependencies,
client: client,
client: remoteDepsClient,
type: type,
all: all
}, next);
}
Expand Down

0 comments on commit 95efc48

Please sign in to comment.