Check that git is installed when instantiating a git resolver

This commit is contained in:
Mat Scales
2013-05-24 17:29:16 +01:00
parent 0ba66d4d47
commit 26f33b9581
2 changed files with 15 additions and 1 deletions

View File

@@ -7,9 +7,22 @@ var rimraf = require('rimraf');
var mout = require('mout');
var Resolver = require('./Resolver');
var createError = require('../../util/createError');
var which = require('which');
var gitChecked = false;
var GitResolver = function (source, options) {
Resolver.call(this, source, options);
if (!gitChecked) {
try {
which.sync('git');
} catch (ex) {
throw new Error('git is not installed or not in the PATH');
}
}
gitChecked = true;
};
util.inherits(GitResolver, Resolver);