Permalink
Browse files

Added functionality to make Jake install missing libraries when testing

  • Loading branch information...
1 parent 3489b5c commit 60ad15e62e0aa7a41a52d28a9ea188c102fdba91 @larzconwell larzconwell committed Jun 27, 2012
Showing with 31 additions and 4 deletions.
  1. +15 −4 Jakefile
  2. +8 −0 test/handlebars_mustache.js
  3. +8 −0 test/jade.js
View
@@ -75,10 +75,21 @@ desc('Run the Geddy tests');
task('test', function () {
var t = jake.Task.testBase;
t.addListener('error', function (e) {
- // TODO: Check the type of error, npm-install the libs, and re-run
- console.error('If you have errors in the templating tests, ' +
- 'install jade and handlebars in the base geddy directory.');
- throw e;
+ var errString = String(e)
+ , module
+ , cmd;
+
+ if(errString.match('Cannot find module')) {
+ module = errString.match(/'[a-zA-Z]*'/)[0].replace(/'/g, '')
+ cmd = 'sudo npm install -g ' + module;
+
+ console.log(module + ' is not installed, Jake will attempt to install it for you.');
+ jake.exec(cmd, function() {
+ console.log('done!');
+
+ t.invoke();
+ });
+ } else throw e;
});
t.invoke();
}, {async: true});
@@ -1,6 +1,14 @@
// Load the basic Geddy toolkit
require('../lib/geddy');
+try {
+ require('handlebars');
+} catch(err) {
+ var events = new (require('events').EventEmitter)
+
+ events.emit('error', err);
+}
+
var Templato = require('../deps/templato')
, Adapter = require('../lib/template/adapters').Adapter
, assert = require('assert')
View
@@ -1,6 +1,14 @@
// Load the basic Geddy toolkit
require('../lib/geddy');
+try {
+ require('jade');
+} catch(err) {
+ var events = new (require('events').EventEmitter)
+
+ events.emit('error', err);
+}
+
var Templato = require('../deps/templato')
, Adapter = require('../lib/template/adapters').Adapter
, assert = require('assert')

0 comments on commit 60ad15e

Please sign in to comment.