mirror of
https://github.com/anomalyco/opencode.git
synced 2026-02-01 22:48:16 +00:00
fix: update pre-push hook to allow caret version differences (#9876)
Co-authored-by: randymcmillan <randymcmillan@protonmail.com>
This commit is contained in:
@@ -1,9 +1,20 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
# Check if bun version matches package.json
|
# Check if bun version matches package.json
|
||||||
EXPECTED_VERSION=$(grep '"packageManager"' package.json | sed 's/.*"bun@\([^"]*\)".*/\1/')
|
# keep in sync with packages/script/src/index.ts semver qualifier
|
||||||
CURRENT_VERSION=$(bun --version)
|
bun -e '
|
||||||
if [ "$CURRENT_VERSION" != "$EXPECTED_VERSION" ]; then
|
import { semver } from "bun";
|
||||||
echo "Error: Bun version $CURRENT_VERSION does not match expected version $EXPECTED_VERSION from package.json"
|
const pkg = await Bun.file("package.json").json();
|
||||||
exit 1
|
const expectedBunVersion = pkg.packageManager?.split("@")[1];
|
||||||
fi
|
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
|
bun typecheck
|
||||||
|
|||||||
Reference in New Issue
Block a user