Skip to content

Commit

Permalink
[minor] A couple of small formatting updates
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Jan 6, 2012
1 parent 5319375 commit f1b3b17
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
4 changes: 2 additions & 2 deletions bin/haibu
Expand Up @@ -25,8 +25,8 @@ if (argv.h || argv.help) {
return util.puts(help);
}

var env = argv.env || 'development',
port = argv.p || 9002;
var env = argv.env || 'development',
port = argv.p || 9002;

if (argv.chroot) {
haibu.use(haibu.chroot, {});
Expand Down
23 changes: 14 additions & 9 deletions lib/haibu.js
Expand Up @@ -31,7 +31,6 @@ require('pkginfo')(module, 'version');
// Set the allowed executables
//
haibu.config.set('allowedExecutables', ['node', 'coffee']);
console.error(haibu.config.stores)

haibu.common = haibu.utils = require('./haibu/common');
haibu.Spawner = require('./haibu/core/spawner').Spawner;
Expand All @@ -46,13 +45,17 @@ haibu.sendResponse = function sendResponse(res, status, body) {
}

haibu.getSpawnOptions = function getSpawnOptions (app) {
var env = app.env, cwd, command = 'node';
var version;
var env = app.env,
command = 'node',
nodeDir,
version,
cwd;

if (haibu.nodeVersions && app.engine) {
version = semver.maxSatisfying(haibu.nodeVersions, (app.engine || {}).node);
var nodeDir = path.join(haibu.engineDir, version);
nodeDir = path.join(haibu.engineDir, version);
}
console.error(haibu.nodeVersions, version)

if (version) {
//
// Add node (should be configured with --no-npm) and -g modules to path of repo
Expand All @@ -67,10 +70,14 @@ console.error(haibu.nodeVersions, version)
var concatLIBRARY_PATH = (process.env.LIBRARY_PATH ? ':' + process.env.LIBRARY_PATH : '');
env.LIBRARY_PATH = path.join(nodeDir, 'lib') + ':' + path.join(nodeDir, 'lib', 'node') + concatLIBRARY_PATH;
}

cwd = nodeDir;
command = path.join(nodeDir, 'bin', 'node');
}
var nodeDir = path.join(haibu.nodeInstallDir, version);return {

nodeDir = path.join(haibu.nodeInstallDir, version);

return {
env: env,
cwd: cwd,
command: command
Expand All @@ -88,6 +95,4 @@ haibu.__defineGetter__('coffee', function () {
});
haibu.__defineGetter__('advanced-replies', function () {
return require('./haibu/plugins/advanced-replies');
});


});
5 changes: 3 additions & 2 deletions lib/haibu/core/spawner.js
Expand Up @@ -83,6 +83,7 @@ Spawner.prototype.spawn = function spawn (repo, callback) {
stdout = [],
options = [],
foreverOptions,
carapaceBin,
error,
drone;

Expand Down Expand Up @@ -153,8 +154,8 @@ Spawner.prototype.spawn = function spawn (repo, callback) {
});

foreverOptions.options.push(script);
var cara = foreverOptions.options.shift();
drone = new forever.Monitor(cara, foreverOptions);
carapaceBin = foreverOptions.options.shift();
drone = new forever.Monitor(carapaceBin, foreverOptions);
drone.on('error', function () {
//
// 'error' event needs to be caught, otherwise
Expand Down
11 changes: 8 additions & 3 deletions lib/haibu/plugins/chroot.js
Expand Up @@ -5,7 +5,8 @@ var fs = require('fs'),
spawn = require('child_process').spawn,
haibu = require('../../haibu');

var chroot = exports;
var chroot = exports,
_getSpawnOptions = haibu.getSpawnOptions;

//
// Name this plugin so it can be accessed by name
Expand Down Expand Up @@ -97,16 +98,20 @@ chroot.argv = function (repo) {
};
};

var _getSpawnOptions = haibu.getSpawnOptions;
haibu.getSpawnOptions = function getSpawnOptions(app) {
var options = _getSpawnOptions.apply(this, arguments);

if (options.env) {
var pattern = new RegExp('(^|:)'+haibu.config.get('chroot').root.replace(/\W/g,'\\$&'));
['CPATH','LIBRARY_PATH','NODE_PREFIX','NODE_PATH','PATH', ].forEach(function(key) {
if (!options[key]) return;
if (!options[key]) {
return;
}

options[key] = options[key].replace(pattern,'$1')
});
}

return options;
}

Expand Down

0 comments on commit f1b3b17

Please sign in to comment.