Skip to content

Commit

Permalink
fix: remove directory if cached directory exists (#508)
Browse files Browse the repository at this point in the history
* fix: remove directory if cached directory exists

* fix: runs remove and move both
  • Loading branch information
jiro4989 authored Sep 15, 2024
1 parent 29ac0d5 commit e515832
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions install_nim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ latest_version() {
sort -V | tail -n 1
}

move_nim_compiler() {
src_dir="$1"
dst_dir="$2"
if [[ -d "$dst_dir" ]]; then
info "remove cached directory (path = $dst_dir)"
rm -rf "$dst_dir"
fi
mv "$src_dir" "$dst_dir"
}

# parse commandline args
nim_version="stable"
nim_install_dir=".nim_runtime"
Expand Down Expand Up @@ -118,15 +128,15 @@ if [[ "$nim_version" = "devel" ]]; then
rm -f "$asset_name"

popd
mv "${work_dir}/outfiles" "${nim_install_dir}"
move_nim_compiler "${work_dir}/outfiles" "${nim_install_dir}"
rm -rf "$work_dir"
else
git clone -b devel --depth 1 https://github.com/nim-lang/Nim
cd Nim
info "build nim compiler (devel)"
./build_all.sh
cd ..
mv Nim "${nim_install_dir}"
move_nim_compiler Nim "${nim_install_dir}"
fi

exit
Expand Down Expand Up @@ -178,4 +188,4 @@ else
tar xf nim.tar.xz
rm -f nim.tar.xz
fi
mv "nim-${nim_version}" "${nim_install_dir}"
move_nim_compiler "nim-${nim_version}" "${nim_install_dir}"

0 comments on commit e515832

Please sign in to comment.