forked from colbymchenry/codegraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocal-install.sh
More file actions
executable file
·41 lines (34 loc) · 1.14 KB
/
local-install.sh
File metadata and controls
executable file
·41 lines (34 loc) · 1.14 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
#!/usr/bin/env bash
# Build the current branch and link it as the global `codegraph` for
# hands-on testing. Replaces any existing global install for as long
# as the symlink is in place.
#
# Usage:
# ./scripts/local-install.sh # build + link
# ./scripts/local-install.sh --undo # unlink + restore the published version
set -euo pipefail
cd "$(dirname "$0")/.."
PKG=$(node -p "require('./package.json').name")
VERSION=$(node -p "require('./package.json').version")
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "${1:-}" = "--undo" ]; then
echo "→ unlinking ${PKG}"
npm unlink -g "${PKG}" >/dev/null 2>&1 || true
echo "→ reinstalling published ${PKG}"
npm install -g "${PKG}"
echo "done: global codegraph -> $(command -v codegraph)"
exit 0
fi
echo "→ building ${PKG} ${VERSION} (${BRANCH})"
npm run build
echo "→ linking globally"
npm link
LINKED=$(command -v codegraph || echo "(not on PATH)")
echo
echo "✓ global codegraph now points to this branch"
echo " binary: ${LINKED}"
echo " branch: ${BRANCH}"
echo " version: ${VERSION}"
echo
echo "To restore the published version:"
echo " ./scripts/local-install.sh --undo"