Permalink
Browse files

[plugin] coffee plugin to have better detection of coffee scripts

  • Loading branch information...
1 parent cd2ab2d commit 633be5753bb79c41ea6af09d6719c82651e0a6ef @bmeck bmeck committed Dec 20, 2011
View
@@ -34,6 +34,10 @@ if (argv.chroot) {
haibu.use(haibu.chroot, {});
}
+if (argv.coffee) {
+ haibu.use(haibu.coffee, {});
+}
+
if (argv['advanced-replies']) {
haibu.use(haibu['advanced-replies'], {});
}
@@ -0,0 +1,33 @@
+var eyes = require('eyes'),
+ haibu = require('../lib/haibu');
+
+// Create a new client for communicating with the haibu server
+var client = new haibu.drone.Client({
+ host: 'localhost',
+ port: 9002
+});
+
+// A basic package.json for a node.js application on Haibu
+var app = {
+ "user": "bmeck",
+ "name": "test",
+ "domain": "devjitsu.com",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/bmeck/hellocoffee.git"
+ },
+ "scripts": {
+ "start": "coffee bin/server"
+ }
+};
+
+// Attempt to start up a new application
+client.start(app, function (err, result) {
+ if (err) {
+ console.log('Error spawning app: ' + app.name);
+ return eyes.inspect(err);
+ }
+
+ console.log('Successfully spawned app:');
+ eyes.inspect(result);
+});
View
@@ -19,7 +19,7 @@ var haibu = module.exports = new flatiron.App({
tmp: '#ROOT/tmp'
}
});
-
+haibu.onAny(function() {console.error(this.event, arguments)})
//
// Expose version through `pkginfo`.
//
@@ -46,6 +46,9 @@ haibu.sendResponse = function sendResponse(res, status, body) {
haibu.__defineGetter__('chroot', function () {
return require('./haibu/plugins/chroot');
});
+haibu.__defineGetter__('coffee', function () {
+ return require('./haibu/plugins/coffee');
+});
haibu.__defineGetter__('advanced-replies', function () {
return require('./haibu/plugins/advanced-replies');
});
@@ -10,7 +10,7 @@ var daemon = require('daemon'),
daemon.chroot(chrootDir);
-var npmInstall = spawn('npm', ['install'], {cwd:appDir});
+var npmInstall = spawn('npm', ['install', process.argv.slice(4)], {cwd:appDir});
npmInstall.stdout.on('data', function (data) {
process.stdout.write(data);
@@ -115,7 +115,11 @@ haibu.common.npm.install = function (dir, target, callback) {
};
haibu.emit('npm:install:start', 'info', meta);
- chroot = spawn('node', [path.join(__dirname, '..', 'common', 'chroot-npm-install.js'), chrootDir, appDir]);
+ chroot = spawn('node', [path.join(__dirname, '..', 'common', 'chroot-npm-install.js'), chrootDir, appDir].concat(
+ Object.keys(dependencies).map(function(depName){
+ return depName + '@' + dependencies[depName];
+ })
+ ));
chroot.stdout.on('data', function (data) {
haibu.emit('npm:install:stdout', 'info', {
@@ -0,0 +1,21 @@
+var coffee = exports;
+
+coffee.name = 'coffee';
+
+coffee.init = function (done) {
+ done();
+};
+
+coffee.attach = function attach(options) {
+}
+
+coffee.argv = function argv(repo) {
+ if (repo.executable === 'coffee') {
+ return {
+ argv: ['--plugin', 'coffee', '--coffee', 'true']
+ }
+ }
+ return {
+ argv: ['--plugin', 'coffee']
+ }
+}
@@ -266,6 +266,7 @@ Repository.prototype.__defineGetter__('startScript', function () {
if (allowedExecutables) {
for(var i = 0; i < allowedExecutables.length; i++) {
if (executable === allowedExecutables[i]) {
+ this.executable = executable;
script = script.substr(executable.length).trim();
break;
}

0 comments on commit 633be57

Please sign in to comment.