function checkTool (tool, minVersion, message, toolFriendlyName) {
    toolFriendlyName = toolFriendlyName || tool;

    // Check whether tool command is available at all
    const tool_command = which.sync(tool, { nothrow: true });
    if (!tool_command) {
        return Promise.reject(new CordovaError(`${toolFriendlyName} was not found. ${message || ''}`));
    }

    // check if tool version is greater than specified one
    return versions.get_tool_version(tool).then(version => {
        version = version.trim();
        return versions.compareVersions(version, minVersion) >= 0
            ? Promise.resolve({ version })
            : Promise.reject(new CordovaError(`Cordova needs ${toolFriendlyName} version ${minVersion} or greater, you have version ${version}. ${message || ''}`));
    });
}
Checks if specific tool is available.
@param  {String} tool       Tool name to check. Known tools are 'xcodebuild' and 'ios-deploy'
@param  {Number} minVersion Min allowed tool version.
@param  {String} message    Message that will be used to reject promise.
@param  {String} toolFriendlyName  Friendly name of the tool, to report to the user. Optional.
@return {Promise}           Returns a promise either resolved with tool version or rejected