HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/design.system/node_modules/@rushstack/terminal/lib/PrefixProxyTerminalProvider.js
"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.PrefixProxyTerminalProvider = void 0;
const node_core_library_1 = require("@rushstack/node-core-library");
/**
 * Wraps an existing {@link ITerminalProvider} that prefixes each line of output with a specified
 * prefix string.
 *
 * @beta
 */
class PrefixProxyTerminalProvider {
    constructor(options) {
        const { terminalProvider } = options;
        this._parentTerminalProvider = terminalProvider;
        if (options.prefix !== undefined) {
            const { prefix } = options;
            this._getPrefix = () => prefix;
        }
        else {
            const { getPrefix } = options;
            this._getPrefix = getPrefix;
        }
        this._isOnNewline = true;
        // eslint-disable-next-line @rushstack/security/no-unsafe-regexp
        this._newlineRegex = new RegExp(`${node_core_library_1.Text.escapeRegExp(terminalProvider.eolCharacter)}|\\n`, 'g');
    }
    /** @override */
    get supportsColor() {
        return this._parentTerminalProvider.supportsColor;
    }
    /** @override */
    get eolCharacter() {
        return this._parentTerminalProvider.eolCharacter;
    }
    /** @override */
    write(data, severity) {
        // We need to track newlines to ensure that the prefix is added to each line
        let currentIndex = 0;
        // eslint-disable-next-line @rushstack/no-new-null
        let newlineMatch;
        while ((newlineMatch = this._newlineRegex.exec(data))) {
            // Extract the line, add the prefix, and write it out with the newline
            const newlineIndex = newlineMatch.index;
            const newIndex = newlineIndex + newlineMatch[0].length;
            const prefix = this._isOnNewline ? this._getPrefix() : '';
            const dataToWrite = `${prefix}${data.substring(currentIndex, newIndex)}`;
            this._parentTerminalProvider.write(dataToWrite, severity);
            // Update the currentIndex to start the search from the char after the newline
            currentIndex = newIndex;
            this._isOnNewline = true;
        }
        // The remaining data is not postfixed by a newline, so write out the data and set _isNewline to false
        const remainingData = data.substring(currentIndex);
        if (remainingData.length) {
            const prefix = this._isOnNewline ? this._getPrefix() : '';
            this._parentTerminalProvider.write(`${prefix}${remainingData}`, severity);
            this._isOnNewline = false;
        }
    }
}
exports.PrefixProxyTerminalProvider = PrefixProxyTerminalProvider;
//# sourceMappingURL=PrefixProxyTerminalProvider.js.map