Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getShellPaths = exports.detectShell = exports.generateCompletion = void 0;
const os_1 = require("os");
const path_1 = require("path");
const BASH_ZSH_TEMPLATE = `if type compdef &>/dev/null; then
    _$1() {
        local IFS=$'\\n'
        compadd -Q -S '' -- \`$2 --compzsh --compgen "\${BUFFER}"\`
    }
    compdef _$1 $2
elif type complete &>/dev/null; then
    _$1() {
        local IFS=$'\\n'
        local cur prev nb_colon
        _get_comp_words_by_ref -n : cur prev
        nb_colon=$(grep -o ":" <<< "$COMP_LINE" | wc -l)
        COMPREPLY=( $(compgen -W '$($2 --compbash --compgen "\${COMP_LINE}")' -- "$cur") )
        __ltrim_colon_completions "$cur"
    }
    complete -o nospace -F _$1 $2
fi`;
const FISH_TEMPLATE = `function _$1
    $2 --compfish --compgen (commandline -pb)
end
complete -f -c $2 -a '(_$1)'`;
function generateBashCompletion(command) {
    const name = command.replace(/-/g, '_');
    return BASH_ZSH_TEMPLATE.replace(/\$1/g, name).replace(/\$2/g, command);
}
function generateZshCompletion(command) {
    const name = command.replace(/-/g, '_');
    return BASH_ZSH_TEMPLATE.replace(/\$1/g, name).replace(/\$2/g, command);
}
function generateFishCompletion(command) {
    const name = command.replace(/-/g, '_');
    return FISH_TEMPLATE.replace(/\$1/g, name).replace(/\$2/g, command);
}
function generateCompletion(command, shell) {
    if (shell === 'fish') {
        return generateFishCompletion(command);
    }
    if (shell === 'zsh') {
        return generateZshCompletion(command);
    }
    if (shell === 'bash') {
        return generateBashCompletion(command);
    }
    return null;
}
exports.generateCompletion = generateCompletion;
function detectShell(shellString) {
    if (shellString.includes('fish')) {
        return 'fish';
    }
    if (shellString.includes('zsh')) {
        return 'zsh';
    }
    if (shellString.includes('bash')) {
        return 'bash';
    }
    return null;
}
exports.detectShell = detectShell;
function getShellPaths(shell) {
    if (shell === 'fish') {
        return [path_1.join(os_1.homedir(), '.config/fish/config.fish')];
    }
    if (shell === 'zsh') {
        return [path_1.join(os_1.homedir(), '.zshrc')];
    }
    if (shell === 'bash') {
        return [path_1.join(os_1.homedir(), '.bashrc'), path_1.join(os_1.homedir(), '.bash_profile')];
    }
    return null;
}
exports.getShellPaths = getShellPaths;