Skip to content

Commit

Permalink
bugfix(@neon-rs/manifest): assertIsPlatformFamily now recognizes Plat…
Browse files Browse the repository at this point in the history
…formName elements
  • Loading branch information
dherman committed Aug 25, 2024
1 parent 4fb181e commit ab3b63d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/manifest/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@neon-rs/manifest",
"private": false,
"version": "0.1.2",
"version": "0.1.3",
"description": "Library for working with Neon package configuration.",
"exports": {
".": {
Expand Down
13 changes: 10 additions & 3 deletions src/manifest/src/platform.cts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ export function isPlatformPreset(x: unknown): x is PlatformPreset {
return (typeof x === 'string') && (x in PRESET);
}

export type PlatformName = NodePlatform | PlatformPreset;

export function assertIsPlatformName(x: unknown): asserts x is PlatformName {
if (!isPlatformPreset(x) && !isNodePlatform(x)) {
throw new RangeError(`invalid platform name: ${x}`);
}
}

export function assertIsPlatformPreset(x: unknown): asserts x is PlatformPreset {
if (!isPlatformPreset(x)) {
throw new RangeError(`invalid platform family preset: ${x}`);
Expand All @@ -55,13 +63,13 @@ export function assertIsPlatformMap(json: unknown, path: string): asserts json i

export function assertIsPlatformFamily(json: unknown, path: string): asserts json is PlatformFamily {
if (typeof json === 'string') {
assertIsPlatformPreset(json);
assertIsPlatformName(json);
return;
}

if (Array.isArray(json)) {
for (const elt of json) {
assertIsPlatformPreset(elt);
assertIsPlatformName(elt);
}
return;
}
Expand All @@ -71,7 +79,6 @@ export function assertIsPlatformFamily(json: unknown, path: string): asserts jso

export type TargetPair = { node: NodePlatform, rust: RustTarget };
export type PlatformMap = { [key in NodePlatform]?: RustTarget };
export type PlatformName = NodePlatform | PlatformPreset;

export type PlatformFamily =
PlatformName
Expand Down

0 comments on commit ab3b63d

Please sign in to comment.