Skip to content

Commit

Permalink
fix: replace all dashes in autocomplete env var (#427)
Browse files Browse the repository at this point in the history
* modifying how to retrieve the cliBinEnvVar

* remove unnecesary asset and modify bash script test
  • Loading branch information
rsuarezmule committed Feb 22, 2023
1 parent ad48a58 commit ac82017
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export abstract class AutocompleteBase extends Command {
}

public get cliBinEnvVar() {
return this.config.bin.toUpperCase().replace('-', '_')
return this.config.bin.toUpperCase().replace(/-/g, '_')
}

public determineShell(shell: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/autocomplete/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class Script extends AutocompleteBase {
const shell = args.shell || this.config.shell
this.errorIfNotSupportedShell(shell)

const binUpcase = this.cliBinEnvVar.replace(/-/g, '_')
const binUpcase = this.cliBinEnvVar
const shellUpcase = shell.toUpperCase()
this.log(
`${this.prefix}${binUpcase}_AC_${shellUpcase}_SETUP_PATH=${path.join(
Expand Down
8 changes: 8 additions & 0 deletions test/commands/autocomplete/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ skipWindows('Create', () => {
expect(cmd.bashSetupScript).to.eq(`OCLIF_EXAMPLE_AC_BASH_COMPFUNC_PATH=${config.cacheDir}/autocomplete/functions/bash/oclif-example.bash && test -f $OCLIF_EXAMPLE_AC_BASH_COMPFUNC_PATH && source $OCLIF_EXAMPLE_AC_BASH_COMPFUNC_PATH;\n`)
})

it('#bashSetupScript wiht more than one dash', async () => {
const confitWithDash = new Config({root})
await confitWithDash.load()
confitWithDash.bin = 'oclif-cli-example'
const cmdWithDash: any = new Create([], confitWithDash)
expect(cmdWithDash.bashSetupScript).to.eq(`OCLIF_CLI_EXAMPLE_AC_BASH_COMPFUNC_PATH=${config.cacheDir}/autocomplete/functions/bash/oclif-cli-example.bash && test -f $OCLIF_CLI_EXAMPLE_AC_BASH_COMPFUNC_PATH && source $OCLIF_CLI_EXAMPLE_AC_BASH_COMPFUNC_PATH;\n`)
})

it('#zshSetupScript', () => {
expect(cmd.zshSetupScript).to.eq(`
fpath=(
Expand Down

0 comments on commit ac82017

Please sign in to comment.