Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
Check for GM binary before run
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Tatarintsev committed Mar 27, 2014
1 parent 9fd3674 commit 5cb7c06
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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));
})
Expand All @@ -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();
Expand Down

0 comments on commit 5cb7c06

Please sign in to comment.