HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/shop.komma.nl/node_modules/@oclif/plugin-not-found/lib/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const color_1 = require("@oclif/color");
const cli_ux_1 = require("cli-ux");
const Levenshtein = require("fast-levenshtein");
const _ = require("lodash");
const hook = async function (opts) {
    const commandIDs = [
        ...opts.config.commandIDs,
        ..._.flatten(opts.config.commands.map(c => c.aliases)),
        'version',
    ];
    if (commandIDs.length === 0)
        return;
    function closest(cmd) {
        return _.minBy(commandIDs, c => Levenshtein.get(cmd, c));
    }
    let binHelp = `${opts.config.bin} help`;
    const idSplit = opts.id.split(':');
    if (await opts.config.findTopic(idSplit[0])) {
        // if valid topic, update binHelp with topic
        binHelp = `${binHelp} ${idSplit[0]}`;
    }
    const suggestion = closest(opts.id);
    this.warn(`${color_1.color.yellow(opts.id)} is not a ${opts.config.bin} command.`);
    let response;
    try {
        response = await cli_ux_1.cli.prompt(`Did you mean ${color_1.color.blueBright(suggestion)}? [y/n]`, { timeout: 4900 });
    }
    catch (error) {
        this.log('');
        this.debug(error);
    }
    if (response === 'y') {
        const argv = process.argv;
        await this.config.runCommand(suggestion, argv.slice(3, argv.length));
        this.exit(0);
    }
    this.error(`Run ${color_1.color.cmd(binHelp)} for a list of available commands.`, { exit: 127 });
};
exports.default = hook;