diff --git a/lib/runner.js b/lib/runner.js index c00888cb0..394950e8f 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -2,8 +2,10 @@ var EventEmitter = require('events').EventEmitter, q = require('q'), + exec = q.denodeify(require('child_process').exec), inherit = require('inherit'), promiseUtils = require('./promise-util'), + GeminiError = require('./gemini-error'), BrowserLauncher = require('./browser/launcher'); @@ -16,8 +18,11 @@ module.exports = inherit(EventEmitter, { runPlans: function(plans) { var _this = this; - this.emit('begin'); - return q(this._prepare()) + return this._checkGM() + .then(function() { + _this.emit('begin'); + return q(_this._prepare()); + }) .then(function() { return promiseUtils.seqMap(plans, _this.runPlan.bind(_this)); }) @@ -29,6 +34,20 @@ module.exports = inherit(EventEmitter, { _prepare: function() { }, + _checkGM: function() { + return exec('gm -version') + .then(function() { + return true; + }) + .fail(function() { + return q.reject(new GeminiError( + 'Unable to find required package: GraphicsMagick', + 'Make sure that GraphicsMagick is installed and availiable in your PATH.\n' + + 'Additonal info and installation instructions:\nhttp://www.graphicsmagick.org/' + )); + }); + }, + runPlan: function(plan) { var _this = this, chains = plan.getChains();