Skip to content

Commit

Permalink
Update Brioche.download(...) to validate Brioche version
Browse files Browse the repository at this point in the history
  • Loading branch information
kylewlacy committed Sep 26, 2024
1 parent f9168c0 commit b70a49e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/std/core/global.bri
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import {
createRecipe,
} from "./recipes";
import { source } from "./source.bri";
import { BRIOCHE_VERSION } from "./runtime.bri";
import { semverMatches } from "./semver.bri";
import { assert } from "./utils.bri";

declare global {
// eslint-disable-next-line
Expand Down Expand Up @@ -171,6 +174,11 @@ declare global {
});
};
(globalThis as any).Brioche.download ??= (url: string): Recipe<File> => {
assert(
semverMatches(BRIOCHE_VERSION, ">=0.1.2"),
"Brioche.download(...) requires Brioche v0.1.2 or greater",
);

const sourceFrame = source({ depth: 1 }).at(0);
if (sourceFrame === undefined) {
throw new Error(`Could not find source file to download ${url}`);
Expand Down

0 comments on commit b70a49e

Please sign in to comment.