function checkTool()

in lib/check_reqs.js [89:105]


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 || ''}`));
    });
}