-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·97 lines (84 loc) · 2.92 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·97 lines (84 loc) · 2.92 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env sh
# kane-cli installer — installs the @testmuai/kane-cli npm package globally.
#
# This script delegates to npm so all install methods (npm / brew / curl)
# produce the same install: the Node.js TUI plus the matching native runner
# binary resolved via optionalDependencies.
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/LambdaTest/kane-cli/main/install.sh | sh
# curl -fsSL https://raw.githubusercontent.com/LambdaTest/kane-cli/main/install.sh | sh -s -- --version 0.2.0
#
# Requires: Node.js 18+ and npm on PATH.
# For an install path that doesn't need Node, use Homebrew:
# brew install LambdaTest/kane/kane-cli
set -eu
PACKAGE="@testmuai/kane-cli"
VERSION=""
# ── Parse args ──────────────────────────────────────────────────────────
while [ $# -gt 0 ]; do
case "$1" in
--version)
VERSION="$2"
shift 2
;;
--help|-h)
cat <<EOF
Usage: install.sh [--version X.Y.Z]
Installs ${PACKAGE} globally via npm.
Options:
--version Specific version to install (default: latest)
Requires Node.js 18+ and npm on PATH. For a non-npm install:
brew install LambdaTest/kane/kane-cli
EOF
exit 0
;;
*)
echo "Unknown option: $1" >&2
exit 1
;;
esac
done
# ── Check prerequisites ────────────────────────────────────────────────
if ! command -v npm >/dev/null 2>&1; then
cat >&2 <<EOF
Error: npm is required but not found on PATH.
Install Node.js 18+ from https://nodejs.org and try again, or use Homebrew:
brew install LambdaTest/kane/kane-cli
EOF
exit 1
fi
# ── Reject Windows ─────────────────────────────────────────────────────
case "$(uname -s 2>/dev/null || echo unknown)" in
MINGW*|MSYS*|CYGWIN*|Windows_NT)
cat >&2 <<EOF
Error: This shell installer is POSIX-only. On Windows, install via npm directly:
npm install -g ${PACKAGE}
EOF
exit 1
;;
esac
# ── Install ────────────────────────────────────────────────────────────
if [ -n "$VERSION" ]; then
SPEC="${PACKAGE}@${VERSION}"
else
SPEC="${PACKAGE}"
fi
echo "Installing ${SPEC} via npm..."
echo
# Try without sudo first (works for nvm/fnm/volta and prefix-configured npm).
# Fall back to sudo only if a permission error suggests it.
if npm install -g "$SPEC"; then
: # success
else
EXIT=$?
if [ $EXIT -eq 13 ] || [ $EXIT -eq 243 ]; then
echo
echo "npm install failed with a permission error. Retrying with sudo..."
sudo npm install -g "$SPEC"
else
exit $EXIT
fi
fi
echo
echo "Installed. Run 'kane-cli --version' to verify."