2 var childProcess = require('child_process');
3 var findVersions = require('find-versions');
5 module.exports = function (bin, cb) {
6 childProcess.exec(bin + ' --version', function (err, stdout, stderr) {
8 if (err.code === 'ENOENT') {
9 err.message = 'Couldn\'t find the `' + bin + '` binary. Make sure it\'s installed and in your $PATH';
15 cb(null, findVersions(stdout.trim() || stderr.trim(), {loose: true})[0]);