forked from gastownhall/gascity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmint.sh
More file actions
executable file
·60 lines (50 loc) · 1.25 KB
/
mint.sh
File metadata and controls
executable file
·60 lines (50 loc) · 1.25 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
#!/usr/bin/env bash
set -euo pipefail
repo_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
docs_dir="$repo_dir/docs"
args=("$@")
if [[ ${#args[@]} -eq 0 ]]; then
args=(dev)
fi
node_major() {
node -p 'process.versions.node.split(".")[0]' 2>/dev/null || true
}
find_node22_bin() {
local prefix
for prefix in /opt/homebrew/opt/node@22 /usr/local/opt/node@22; do
if [[ -x "$prefix/bin/node" ]]; then
printf '%s/bin\n' "$prefix"
return 0
fi
done
if command -v brew >/dev/null 2>&1; then
prefix=$(brew --prefix node@22 2>/dev/null || true)
if [[ -n "$prefix" && -x "$prefix/bin/node" ]]; then
printf '%s/bin\n' "$prefix"
return 0
fi
fi
return 1
}
major=$(node_major)
if [[ "$major" =~ ^[0-9]+$ ]] && (( major < 25 )); then
cd "$docs_dir"
exec npx --yes mint@latest "${args[@]}"
fi
if node22_bin=$(find_node22_bin); then
export PATH="$node22_bin:$PATH"
cd "$docs_dir"
exec npx --yes mint@latest "${args[@]}"
fi
cat >&2 <<EOF
Mintlify does not support Node 25+.
Use Node 22 LTS to preview the docs. For example:
nvm use 22
fnm use 22
volta install node@22
On macOS with Homebrew:
brew install node@22
cd "$repo_dir"
PATH="/opt/homebrew/opt/node@22/bin:$PATH" ./mint.sh dev
EOF
exit 1