-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
52 lines (45 loc) · 1.23 KB
/
Copy pathinstall.sh
File metadata and controls
52 lines (45 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
# Install opencode-git-tools (global OpenCode plugin + optional git hooks)
# Usage:
# bash install.sh
# bash install.sh --hooks
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
HOOKS=false
for arg in "$@"; do
case "$arg" in
--hooks) HOOKS=true ;;
-h|--help)
echo "Usage: bash install.sh [--hooks]"
echo " --hooks Install pre-commit hooks in the current git project"
exit 0
;;
esac
done
run_node_script() {
local script="$1"
if command -v node >/dev/null 2>&1; then
node "$script"
elif command -v bun >/dev/null 2>&1; then
bun run "$script"
else
echo "Node.js or Bun is required." >&2
exit 1
fi
}
echo "opencode-git-tools installer"
echo "============================"
echo ""
echo "[1/2] Installing global OpenCode plugin..."
run_node_script "$ROOT/scripts/install-global.mjs"
if [ "$HOOKS" = true ]; then
echo ""
echo "[2/2] Installing git pre-commit hooks in current project..."
run_node_script "$ROOT/scripts/install-git-hooks.mjs"
else
echo ""
echo "[2/2] Skipped git hooks (use --hooks to install in current repo)."
fi
echo ""
echo "Done! Restart OpenCode to activate the plugin."
echo 'Verify: opencode run "call gitStatus and show the result"'