Skip to content

Commit d6a07d2

Browse files
validate semver first
1 parent 24d9b1a commit d6a07d2

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/kernel.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {LineParseResultCommand} from "./programs/core/ash/parser";
1212

1313
import {NEWLINE, type WrappedTerminal} from "./term_ctl";
1414

15+
import semver_validate from "semver/functions/valid";
1516
import semver_compare from "semver/functions/compare"
1617

1718
const CURRENT_API_COMPAT = "2.0.0";
@@ -89,6 +90,10 @@ export class Kernel {
8990
compat = program.compat;
9091
}
9192

93+
if (!semver_validate(compat)) {
94+
throw new Error(`Program ${program.name} has an invalid compat SemVer: ${compat}`);
95+
}
96+
9297
if (semver_compare(compat, CURRENT_API_COMPAT) < 0) {
9398
throw new Error(`Program ${program.name} is not compatible with OllieOS 2. (Add compat: "2.0.0" to the program object to mark it as ported.)`);
9499
}

0 commit comments

Comments
 (0)