Skip to content

Commit

Permalink
Merge pull request #133 from nodejitsu/vNext
Browse files Browse the repository at this point in the history
Battle hardening
  • Loading branch information
indexzero committed Feb 7, 2013
2 parents bd76519 + 6571919 commit 3577ee2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
7 changes: 1 addition & 6 deletions lib/haibu/core/spawner.js
Expand Up @@ -32,12 +32,7 @@ haibu.getSpawnOptions = function getSpawnOptions (app) {
}
version = semver.maxSatisfying(nodeVersions, engine);
if (!version) {
var err = new Error([
'Haibu could not find a node.js version satisfying specified',
'node.js engine `' + String(engine) + '`. Try specifying a different '
+ 'version of node.js',
'in your package.json, such as `0.8.x`.'
].join('\n'));
var err = new Error('Error spawning drone: no matching engine found');
err.blame = {
type: 'user',
message: 'Repository configuration'
Expand Down
7 changes: 5 additions & 2 deletions lib/haibu/repositories/repository.js
Expand Up @@ -77,7 +77,8 @@ Repository.prototype.validate = function (keys, app) {
// with this repository instance on this system.
//
Repository.prototype.installDependencies = function (callback) {
var self = this;
var noNpm = haibu.config.get('no-npm'),
self = this;

fs.readFile(path.join(this.homeDir, 'package.json'), function (err, data) {
if (!err) {
Expand All @@ -93,7 +94,9 @@ Repository.prototype.installDependencies = function (callback) {
}
}

haibu.common.npm.install(self.homeDir, self.app, callback);
return noNpm !== true
? haibu.common.npm.install(self.homeDir, self.app, callback)
: callback(null, self.app.dependencies);
});
};

Expand Down
16 changes: 8 additions & 8 deletions lib/haibu/repositories/tar.js
Expand Up @@ -7,8 +7,6 @@

var fs = require('fs'),
util = require('util'),
zlib = require('zlib'),
tar = require('tar'),
haibu = require('../../haibu'),
RemoteFile = require('./remote-file').RemoteFile;

Expand Down Expand Up @@ -49,14 +47,16 @@ Tar.prototype.init = function (callback) {
return callback(err);
}

var files = [];
var child = require('child_process').spawn('tar', ['-C', self.appDir, '-xzf', '-']),
files = [];

var extractor = new tar.Extract({ path: self.appDir });
extractor.on('entry', function (entry) {
files.push(entry.path);
});
fs.createReadStream(packageFile).pipe(child.stdin);

child.on('exit', function (statusCode) {
if (statusCode) {
return callback(new Error('tar exited with code: ' + statusCode));
}

fs.createReadStream(packageFile).pipe(zlib.Gunzip()).pipe(extractor).on('end', function () {
self.stat(function (err, exists) {
if (err) {
return callback(err);
Expand Down

0 comments on commit 3577ee2

Please sign in to comment.