File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change 11#! /bin/sh
2+ set -e
23# Check if bun version matches package.json
3- EXPECTED_VERSION=$( grep ' "packageManager"' package.json | sed ' s/.*"bun@\([^"]*\)".*/\1/' )
4- CURRENT_VERSION=$( bun --version)
5- if [ " $CURRENT_VERSION " != " $EXPECTED_VERSION " ]; then
6- echo " Error: Bun version $CURRENT_VERSION does not match expected version $EXPECTED_VERSION from package.json"
7- exit 1
8- fi
4+ # keep in sync with packages/script/src/index.ts semver qualifier
5+ bun -e '
6+ import { semver } from "bun";
7+ const pkg = await Bun.file("package.json").json();
8+ const expectedBunVersion = pkg.packageManager?.split("@")[1];
9+ if (!expectedBunVersion) {
10+ throw new Error("packageManager field not found in root package.json");
11+ }
12+ const expectedBunVersionRange = `^${expectedBunVersion}`;
13+ if (!semver.satisfies(process.versions.bun, expectedBunVersionRange)) {
14+ throw new Error(`This script requires bun@${expectedBunVersionRange}, but you are using bun@${process.versions.bun}`);
15+ }
16+ if (process.versions.bun !== expectedBunVersion) {
17+ console.warn(`Warning: Bun version ${process.versions.bun} differs from expected ${expectedBunVersion}`);
18+ }
19+ '
920bun typecheck
You can’t perform that action at this time.
0 commit comments