"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.VARIANT_PARAMETER = void 0;
exports.getVariantAsync = getVariantAsync;
const EnvironmentConfiguration_1 = require("./EnvironmentConfiguration");
const RushConstants_1 = require("../logic/RushConstants");
/**
 * Provides the parameter configuration for '--variant'.
 */
exports.VARIANT_PARAMETER = {
    parameterLongName: '--variant',
    argumentName: 'VARIANT',
    description: 'Run command using a variant installation configuration',
    environmentVariable: EnvironmentConfiguration_1.EnvironmentVariableNames.RUSH_VARIANT
};
async function getVariantAsync(variantsParameter, rushConfiguration, defaultToCurrentlyInstalledVariant) {
    let variant = variantsParameter === null || variantsParameter === void 0 ? void 0 : variantsParameter.value;
    if (variant && !rushConfiguration.variants.has(variant)) {
        throw new Error(`The variant "${variant}" is not defined in ${RushConstants_1.RushConstants.rushJsonFilename}`);
    }
    if (!variant && defaultToCurrentlyInstalledVariant) {
        variant = await rushConfiguration.getCurrentlyInstalledVariantAsync();
    }
    return variant;
}
//# sourceMappingURL=Variants.js.map