Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[fix] allow the versions object to be optional in cases where it does…
…nt exist (ie Roles)
  • Loading branch information
jcrugzz committed Jul 8, 2013
1 parent 3661020 commit 4b6ab86
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions lib/dependencies.js
Expand Up @@ -52,19 +52,24 @@ var dependencies = module.exports = function (options, callback) {

//
// If the system `name` has already been fetched
// then just set it in the tree.
// then just set it in the tree.
//
if (all[name]) {
tree[name] = all[name];
return next();
}

depsClient.get(name, function (err, system) {
if (err) {
return next(new Error('Error fetching ' + name + ': ' + err.message.replace(/Error /, '')));
}

var versions = Object.keys(system.versions),
//
// Remark: So here is an interesting story where we are using roles like
// systems and they dont have a bunch of versions or anything like that.
// First step pretend we have an array of versions.
//
var versions = system.versions && Object.keys(system.versions) || [],
required = version || "*",
invalid,
osdeps;
Expand All @@ -73,12 +78,18 @@ var dependencies = module.exports = function (options, callback) {
versions,
version || system.version
) || version;

if (!system.versions[version]) {
//
// Remark: Next step is to bypass this error with some clever magic as we
// dont really care about versions with roles
//
if (system.versions && !system.versions[version]) {
return next(new Error('Could not resolve dependency: ' + [name, version].join('@')));
}

system = system.versions[version],
//
// Remark: Now we are back where we began where we either use
// a particular version or default back to the original system/role.
//
system = system.versions && system.versions[version] || system,
system.version = version;
system.required = required;
system.runlist = system.runlist || [];
Expand All @@ -95,7 +106,7 @@ var dependencies = module.exports = function (options, callback) {
if (invalid) {
return next(invalid);
}

//
// Set the system in the tree and the
// set of all systems we've fetched.
Expand Down Expand Up @@ -208,7 +219,7 @@ dependencies.of = function (system, tree) {
dependencies.maxSatisfying = function (options, callback) {
var system = options.system,
client = options.client;

async.waterfall([
//
// 1. Get the current OS with wtfos
Expand Down

0 comments on commit 4b6ab86

Please sign in to comment.