summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorCaleb Norton <[email protected]>2026-01-21 14:40:01 -0600
committerGitHub <[email protected]>2026-01-21 14:40:01 -0600
commit0b63cae1aeb58f9ada3c0c703112f93add67d5eb (patch)
tree04b0eac58e1e20c6667f5fe39d11b26d4087f83f
parentb7b2eae20c7c4276343e5f1f0e5feaeb5ac3a0ef (diff)
downloadopencode-0b63cae1aeb58f9ada3c0c703112f93add67d5eb.tar.gz
opencode-0b63cae1aeb58f9ada3c0c703112f93add67d5eb.zip
fix: update pre-push hook to allow caret version differences (#9876)
Co-authored-by: randymcmillan <[email protected]>
-rwxr-xr-x.husky/pre-push23
1 files changed, 17 insertions, 6 deletions
diff --git a/.husky/pre-push b/.husky/pre-push
index 2fd039d56..5d3cc5341 100755
--- a/.husky/pre-push
+++ b/.husky/pre-push
@@ -1,9 +1,20 @@
#!/bin/sh
+set -e
# Check if bun version matches package.json
-EXPECTED_VERSION=$(grep '"packageManager"' package.json | sed 's/.*"bun@\([^"]*\)".*/\1/')
-CURRENT_VERSION=$(bun --version)
-if [ "$CURRENT_VERSION" != "$EXPECTED_VERSION" ]; then
- echo "Error: Bun version $CURRENT_VERSION does not match expected version $EXPECTED_VERSION from package.json"
- exit 1
-fi
+# keep in sync with packages/script/src/index.ts semver qualifier
+bun -e '
+import { semver } from "bun";
+const pkg = await Bun.file("package.json").json();
+const expectedBunVersion = pkg.packageManager?.split("@")[1];
+if (!expectedBunVersion) {
+ throw new Error("packageManager field not found in root package.json");
+}
+const expectedBunVersionRange = `^${expectedBunVersion}`;
+if (!semver.satisfies(process.versions.bun, expectedBunVersionRange)) {
+ throw new Error(`This script requires bun@${expectedBunVersionRange}, but you are using bun@${process.versions.bun}`);
+}
+if (process.versions.bun !== expectedBunVersion) {
+ console.warn(`Warning: Bun version ${process.versions.bun} differs from expected ${expectedBunVersion}`);
+}
+'
bun typecheck