Skip to content

Commit

Permalink
improve install script returning more information and cargo build com…
Browse files Browse the repository at this point in the history
…mand
  • Loading branch information
henrybarreto committed Nov 20, 2022
1 parent e61ad42 commit ed60448
Showing 1 changed file with 33 additions and 16 deletions.
49 changes: 33 additions & 16 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
#!/usr/bin/env sh

script() {
echo "#!/usr/bin/env sh" >> "$binary_path"
echo "" >> "$binary_path"
echo "path=\$($build_path \$@)" >> "$binary_path"
echo "if [ \"\$path\" != \"\" ]; then" >> "$binary_path"
echo " echo \"moving to \$path\"" >> "$binary_path"
echo " cd \"\$path\"" >> "$binary_path"
echo " \$SHELL" >> "$binary_path"
echo " echo \"exiting from workspace \$path\"" >> "$binary_path"
echo "fi" >> "$binary_path"
chmod +x "$binary_path"
}

build_path="$(pwd)/target/release/wk"

if [ ! -f "$build_path" ]; then
echo "wk not found at $build_path"
echo "Running cargo build --release"
if cargo build --release; then
echo "wk built successfully"
else
echo "Failed to build wk"
exit 1
fi
fi

binary_path="$HOME/.local/bin/wk"

if [ -f "$binary_path" ]; then
echo "Wk is already installed!"
echo "Uninstalling wk from $binary_path"
echo "wk is already installed!"
echo "Updating wk from $binary_path"
rm "$binary_path"
echo "Uninstalled!"
script
echo "wk updated successfully"
else
echo "Installing wk to $binary_path"
script
echo "wk installed successfully"
fi

echo "Installing wk to $binary_path"
echo "#!/usr/bin/env sh" >> "$binary_path"
echo "" >> "$binary_path"
echo "path=\$($build_path \$@)" >> "$binary_path"
echo "if [ \"\$path\" != \"\" ]; then" >> "$binary_path"
echo " echo \"moving to \$path\"" >> "$binary_path"
echo " cd \"\$path\"" >> "$binary_path"
echo " \$SHELL" >> "$binary_path"
echo " echo \"exiting from workspace \$path\"" >> "$binary_path"
echo "fi" >> "$binary_path"
chmod +x "$binary_path"
echo "Installed!"

0 comments on commit ed60448

Please sign in to comment.