Skip to content

Commit

Permalink
fix: better error handling when build module
Browse files Browse the repository at this point in the history
  • Loading branch information
Aloxaf committed Feb 25, 2024
1 parent 325b639 commit cdc34ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
11 changes: 10 additions & 1 deletion fzf-tab.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,16 @@ toggle-fzf-tab() {
}

build-fzf-tab-module() {
-ftb-build-module $@
{
pushd -q $FZF_TAB_HOME/modules
if -ftb-build-module $@; then
print -P "%F{green}%BThe module has been built successfully. Please restart zsh to apply it.%f%b"
else
print -P -u2 "%F{red}%BThe module building has failed. See the output above for details.%f%b"
fi
} always {
popd -q
}
}

zmodload zsh/zutil
Expand Down
14 changes: 1 addition & 13 deletions lib/-ftb-build-module
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/hint/zsh
emulate -LR zsh -o extended_glob
emulate -LR zsh -o extended_glob -o err_exit

local zsh_version=${1:-${FZF_TAB_ZSH_SRC_VERSION:-$ZSH_VERSION}}

Expand All @@ -12,8 +12,6 @@ else
nproc=$(nproc)
fi

pushd -q $FZF_TAB_HOME/modules

# clone zsh source code if not exists
if [[ ! -d ./zsh/$zsh_version ]]; then
git clone --depth=1 --branch zsh-$zsh_version https://github.com/zsh-users/zsh ./zsh/$zsh_version
Expand All @@ -30,16 +28,6 @@ if [[ ! -f ./Makefile ]]; then
./configure --disable-gdbm --disable-pcre --without-tcsetpgrp --prefix=/tmp/zsh-fzf-tab-module ${bundle:+DL_EXT=bundle}
fi
make -j$nproc
ret=$?

if (( $ret != 0 )); then
print -P -u2 "%F{red}%BThe module building has failed. See the output above for details.%f%b"
return $ret
fi

# we only need aloxaf/fzftab.so
mv ./Src/Modules/fzftab.(so|bundle) $FZF_TAB_HOME/modules/Src/aloxaf/

popd -q

print -P "%F{green}%BThe module has been built successfully. Please restart zsh to apply it.%f%b"

0 comments on commit cdc34ee

Please sign in to comment.