"use strict";
/*
 * Copyright 2022 Fernando Boucquez
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.Utils = void 0;
const OSUtils_1 = require("./OSUtils");
/**
 * Random utility methods that don't fit other place.
 */
class Utils {
    static secureString(text) {
        const regex = new RegExp('[0-9a-fA-F]{64}', 'g');
        return text.replace(regex, 'HIDDEN_KEY');
    }
    static validateIsDefined(value, message) {
        if (value === undefined || value === null) {
            throw new Error(message);
        }
    }
    static validateIsTrue(value, message) {
        if (!value) {
            throw new Error(message);
        }
    }
    static logSameLineMessage(message) {
        process.stdout.write(OSUtils_1.OSUtils.isWindows() ? '\x1b[0G' : '\r');
        process.stdout.write(message);
    }
}
exports.Utils = Utils;
