// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import * as path from 'node:path';
import { User } from '@rushstack/node-core-library';
import { EnvironmentConfiguration } from './EnvironmentConfiguration';
/**
 * This class provides global folders that are used for rush's internal install locations.
 *
 * @internal
 */
export class RushGlobalFolder {
    constructor() {
        // Because RushGlobalFolder is used by the front-end VersionSelector before EnvironmentConfiguration
        // is initialized, we need to read it using a special internal API.
        const rushGlobalFolderOverride = EnvironmentConfiguration._getRushGlobalFolderOverride(process.env);
        if (rushGlobalFolderOverride !== undefined) {
            this.path = rushGlobalFolderOverride;
        }
        else {
            this.path = path.join(User.getHomeFolder(), '.rush');
        }
        const normalizedNodeVersion = process.version.match(/^[a-z0-9\-\.]+$/i)
            ? process.version
            : 'unknown-version';
        this.nodeSpecificPath = path.join(this.path, `node-${normalizedNodeVersion}`);
    }
}
//# sourceMappingURL=RushGlobalFolder.js.map