Skip to content

Commit

Permalink
Merge pull request #88 from opsmezzo/external-deps
Browse files Browse the repository at this point in the history
External deps
  • Loading branch information
mmalecki committed Jul 10, 2013
2 parents d181142 + e7062b7 commit f7902f9
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
56 changes: 56 additions & 0 deletions lib/quill/composer/lifecycle.js
Expand Up @@ -13,6 +13,8 @@ var assert = require('assert'),
fstream = require('fstream'),
semver = require('semver'),
wtfos = require('wtfos'),
wtfpm = require('wtfpm'),
pma = require('pma'),
composer = require('./index'),
quill = require('../../quill'),
common = quill.common,
Expand Down Expand Up @@ -264,6 +266,60 @@ exports.run = function (action, systems, callback) {
? next(null, runlist)
: next(null, composer.runlist.localize(runlist, installed, quill.log));
},
function installExternalDeps(runlist, next) {
wtfpm(function (err, managers) {
if (err) {
return next(err);
}

var externalRunlists = {};

quill.log.info('External package managers found: ' + managers.join(', '));

runlist.forEach(function (system) {
if (!system.externalDependencies) {
return;
}

Object.keys(system.externalDependencies).filter(function (manager) {
return managers.indexOf(manager) !== -1;
}).forEach(function (manager) {
if (!externalRunlists[manager]) {
externalRunlists[manager] = [];
}

Array.prototype.push.apply(
externalRunlists[manager],
system.externalDependencies[manager]
);
});
});

async.forEachSeries(Object.keys(externalRunlists), function (manager, next) {
var command = pma(manager, 'install', externalRunlists[manager]),
app = command[0],
args = command.slice(1),
child;

quill.log.info('Installing with ' + manager + ': ' + externalRunlists[manager]);

child = spawn(app, args);

child.stdout.on('data', quill.emit.bind(quill, ['run', 'stdout'], ''));
child.stderr.on('data', quill.emit.bind(quill, ['run', 'stderr'], ''));

child.on('exit', function (code) {
if (code !== 0) {
return next(new Error(app + ' exited while installing ' + args));
}

next();
});
}, function (err) {
next(err, runlist);
});
});
},
composer.installed.add
], function (err) {
if (err) {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -32,7 +32,9 @@
"system.json": "~1.2.2",
"union": "0.3.6",
"wtfos": "0.0.3",
"rimraf": "2.2.x"
"rimraf": "2.2.x",
"wtfpm": "1.0.x",
"pma": "1.0.x"
},
"devDependencies": {
"nock": "0.16.x",
Expand Down

0 comments on commit f7902f9

Please sign in to comment.