HEX
Server: nginx/1.24.0
System: Linux nowruzgan 6.8.0-57-generic #59-Ubuntu SMP PREEMPT_DYNAMIC Sat Mar 15 17:40:59 UTC 2025 x86_64
User: babak (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/dev/shahnamag/back-end/node_modules/@nestjs/core/repl/repl-native-commands.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defineDefaultCommandsOnRepl = defineDefaultCommandsOnRepl;
/**
 * Displays a list of available commands in the REPL alongside with their
 * descriptions.
 * (c) This code was inspired by the 'help' command from Node.js core:
 * {@link https://github.com/nodejs/node/blob/58b60c1393dd65cd228a8b0084a19acd2c1d16aa/lib/repl.js#L1741-L1759}
 */
function listAllCommands(replServer) {
    Object.keys(replServer.commands)
        .sort()
        .forEach(name => {
        const cmd = replServer.commands[name];
        if (cmd) {
            replServer.output.write(`${name}\t${cmd.help || ''}\n`);
        }
    });
}
function defineDefaultCommandsOnRepl(replServer) {
    replServer.defineCommand('help', {
        help: 'Show REPL options',
        action(name) {
            this.clearBufferedCommand();
            if (name) {
                // Considering native commands before native nestjs injected functions.
                const nativeCommandOrFunction = this.commands[name] || this.context[name];
                // NOTE: If the command was retrieve from the context, it will have a `help`
                // getter property that outputs the helper message and returns undefined.
                // But if the command was retrieve from the `commands` object, it will
                // have a `help` property that returns the helper message.
                const helpMessage = nativeCommandOrFunction?.help;
                if (helpMessage) {
                    this.output.write(`${helpMessage}\n`);
                }
            }
            else {
                listAllCommands(this);
                this.output.write('\n\n');
                this.context.help();
                this.output.write('\nPress Ctrl+C to abort current expression, Ctrl+D to exit the REPL\n');
            }
            this.displayPrompt();
        },
    });
}