"use strict";
var os = require("os"), semver = require("semver"), util = require("util");
var versionsCausingFailure = ["0.10.34", "4.0.0", "4.2.0", "5.0.0"];
var minimumRequiredVersion = "4.2.1";
function verifyNodeVersion(supportedVersionsRange, cliName) {
    require("colors");
    var nodeVer = process.version.substr(1);
    if (versionsCausingFailure.indexOf(nodeVer) !== -1 || !semver.valid(nodeVer) || semver.lt(nodeVer, minimumRequiredVersion)) {
        console.error(util.format("%sNode.js '%s' is not supported. To be able to work with %s CLI, install any Node.js version in the following range: %s.%s", os.EOL, nodeVer, cliName, supportedVersionsRange, os.EOL).red.bold);
        process.exit(1);
    }
    var checkSatisfied = semver.satisfies(nodeVer, supportedVersionsRange);
    if (!checkSatisfied) {
        console.log(util.format("%sSupport for Node.js %s is not verified. This CLI might not install or run properly.%s", os.EOL, nodeVer, os.EOL).yellow.bold);
    }
}
exports.verifyNodeVersion = verifyNodeVersion;
