-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve install script returning more information and cargo build com…
…mand
- Loading branch information
1 parent
e61ad42
commit ed60448
Showing
1 changed file
with
33 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!" |