plugins/go: simplify _bash-it-gopath-pathmunge()
parent
c515f78acb
commit
636cf50ede
|
|
@ -19,18 +19,14 @@ export GOPATH="${GOPATH:-$(go env GOPATH)}"
|
|||
_bash-it-gopath-pathmunge() {
|
||||
_about 'Ensures paths in GOPATH are added to PATH using pathmunge, with /bin appended'
|
||||
_group 'go'
|
||||
if [[ -z $GOPATH ]]; then
|
||||
echo 'GOPATH empty' >&2
|
||||
if [[ -z "${GOPATH:-}" ]]; then
|
||||
_log_warning 'GOPATH empty'
|
||||
return 1
|
||||
fi
|
||||
local paths i
|
||||
local paths apath
|
||||
IFS=: read -r -a paths <<< "$GOPATH"
|
||||
i=${#paths[@]}
|
||||
while [[ $i -gt 0 ]]; do
|
||||
i=$((i - 1))
|
||||
if [[ -n "${paths[i]}" ]]; then
|
||||
pathmunge "${paths[i]}/bin" || true
|
||||
fi
|
||||
for apath in "${paths[@]}"; do
|
||||
pathmunge "${apath}/bin" || true
|
||||
done
|
||||
}
|
||||
_bash-it-gopath-pathmunge
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ function setup_go_path()
|
|||
setup_go_path "$BASH_IT/test/fixtures/go/gopath"
|
||||
setup_go_path "$BASH_IT/test/fixtures/go/gopath2"
|
||||
load ../../plugins/available/go.plugin
|
||||
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "$BASH_IT/test/fixtures/go/gopath2/bin:$BASH_IT/test/fixtures/go/gopath/bin"
|
||||
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "$BASH_IT/test/fixtures/go/gopath/bin:$BASH_IT/test/fixtures/go/gopath2/bin"
|
||||
}
|
||||
|
||||
@test 'plugins go: multiple entries in GOPATH, with space' {
|
||||
|
|
@ -61,7 +61,7 @@ function setup_go_path()
|
|||
setup_go_path "$BASH_IT/test/fixtures/go/gopath"
|
||||
setup_go_path "$BASH_IT/test/fixtures/go/go path"
|
||||
load ../../plugins/available/go.plugin
|
||||
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "$BASH_IT/test/fixtures/go/go path/bin:$BASH_IT/test/fixtures/go/gopath/bin"
|
||||
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "$BASH_IT/test/fixtures/go/gopath/bin:$BASH_IT/test/fixtures/go/go path/bin"
|
||||
}
|
||||
|
||||
@test 'plugins go: multiple entries in GOPATH, with escaped space' {
|
||||
|
|
|
|||
Loading…
Reference in New Issue