Initial commit
[yaffs-website] / node_modules / bin-version / index.js
1 'use strict';
2 var childProcess = require('child_process');
3 var findVersions = require('find-versions');
4
5 module.exports = function (bin, cb) {
6         childProcess.exec(bin + ' --version', function (err, stdout, stderr) {
7                 if (err) {
8                         if (err.code === 'ENOENT') {
9                                 err.message = 'Couldn\'t find the `' + bin + '` binary. Make sure it\'s installed and in your $PATH';
10                         }
11
12                         return cb(err);
13                 }
14
15                 cb(null, findVersions(stdout.trim() || stderr.trim(), {loose: true})[0]);
16         });
17 };