Files
keep/scripts/install-cli.sh

24 lines
840 B
Bash
Raw Permalink Normal View History

#!/bin/sh
# Builds keep and symlinks the CLI onto PATH as a real `keep` command --
# no `npm run cli --` from inside this repo, no npm global install (which
# needs root/write access to the system Node install on most hosts).
#
# Since this is a symlink to dist/cli/index.js rather than a copy, a
# future `git pull && npm run build` here is the entire upgrade story --
# no need to re-run this script.
set -eu
cd "$(dirname "$0")/.."
BIN_DIR="${KEEP_BIN_DIR:-$HOME/.local/bin}"
mkdir -p "$BIN_DIR"
npm run build
chmod +x dist/cli/index.js
ln -sf "$(pwd)/dist/cli/index.js" "$BIN_DIR/keep"
echo "keep CLI linked: $BIN_DIR/keep -> $(pwd)/dist/cli/index.js"
case ":$PATH:" in
*":$BIN_DIR:"*) echo "$BIN_DIR is already on PATH — try: keep --help" ;;
*) echo "warning: $BIN_DIR is not on PATH — add it to your shell profile" ;;
esac