-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·43 lines (35 loc) · 1.46 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·43 lines (35 loc) · 1.46 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
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell
#
# Fetch and build the pinned tree-sitter-rescript grammar.
# Output goes under ../../.build/tree-sitter-rescript/ (gitignored).
set -euo pipefail
UPSTREAM_COMMIT="990214a83f25801dfe0226bd7e92bb71bba1970f"
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
# tools/vendor/ is the repo's convention for fetched-not-committed deps
# (see .gitignore line 103, mirrors the WASI adapter provisioning).
BUILD_DIR="${REPO_ROOT}/tools/vendor/tree-sitter-rescript"
if ! command -v tree-sitter >/dev/null 2>&1; then
echo "error: tree-sitter CLI not found on PATH" >&2
echo " install via either:" >&2
echo " cargo install tree-sitter-cli (Rust-native, repo-preferred)" >&2
echo " npm install -g tree-sitter-cli (Node-based, also fine)" >&2
exit 2
fi
if ! command -v git >/dev/null 2>&1; then
echo "error: git not found on PATH" >&2
exit 2
fi
mkdir -p "$(dirname "$BUILD_DIR")"
if [ -d "$BUILD_DIR/.git" ]; then
git -C "$BUILD_DIR" fetch --quiet origin "$UPSTREAM_COMMIT" || true
git -C "$BUILD_DIR" checkout --quiet "$UPSTREAM_COMMIT"
else
rm -rf "$BUILD_DIR"
git clone --quiet https://github.com/rescript-lang/tree-sitter-rescript.git "$BUILD_DIR"
git -C "$BUILD_DIR" checkout --quiet "$UPSTREAM_COMMIT"
fi
cd "$BUILD_DIR"
tree-sitter generate
echo "tree-sitter-rescript built at ${BUILD_DIR} (commit ${UPSTREAM_COMMIT})"