Skip to content

Commit

Permalink
Upgrade to deno 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
smack0007 committed Oct 22, 2024
1 parent 68337f3 commit d357f68
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
- uses: actions/checkout@v3

- name: Deno Setup
uses: denoland/setup-deno@v1
uses: denoland/setup-deno@v2
with:
deno-version: "1.46.2"
deno-version: v2.0.2

- name: Build
run: |
Expand Down
30 changes: 17 additions & 13 deletions src/deno/_library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function getLibraryPaths(libraryName: string): string[] {
// On Debain libSDL2_image and libSDL2_ttf only have symbolic links with this format so
// search for those globally as well.
libraryPaths.push(
libraryPrefix + libraryName + "-2.0" + librarySuffix + ".0"
libraryPrefix + libraryName + "-2.0" + librarySuffix + ".0",
);
}

Expand All @@ -66,7 +66,7 @@ function getLibraryPaths(libraryName: string): string[] {
libraryPaths.push(
...ldLibraryPath
.split(":")
.map((libraryPath) => join(libraryPath, fullLibraryName))
.map((libraryPath) => join(libraryPath, fullLibraryName)),
);
}
}
Expand All @@ -88,7 +88,7 @@ function getLibraryPaths(libraryName: string): string[] {
}

libraryPaths.push(
...searchPaths.map((libraryPath) => join(libraryPath, fullLibraryName))
...searchPaths.map((libraryPath) => join(libraryPath, fullLibraryName)),
);

return libraryPaths;
Expand All @@ -97,11 +97,9 @@ function getLibraryPaths(libraryName: string): string[] {
export function denoLoadLibrary<T extends DynamicLibraryInterface>(
libraryName: string,
symbols: T,
libraryPath?: string
libraryPath?: string,
): DynamicLibrary<T> {
const libraryPaths = libraryPath
? [libraryPath]
: getLibraryPaths(libraryName);
const libraryPaths = libraryPath ? [libraryPath] : getLibraryPaths(libraryName);
const errors: Record<string, Error> = {};

for (const libraryPath of libraryPaths) {
Expand All @@ -110,22 +108,28 @@ export function denoLoadLibrary<T extends DynamicLibraryInterface>(
libraryPath,
// Cast the symbols as any in order to prevent a type checking bug.
// deno-lint-ignore no-explicit-any
symbols as any
symbols as any,
) as DynamicLibrary<T>;
console.debug(`SDL_ts: Loaded ${libraryName} from "${libraryPath}"`);
return result;
} catch (error) {
errors[libraryPath] = error;
if (error instanceof Error) {
errors[libraryPath] = error;
} else {
throw error;
}
}
}

throw new SDLError(
`Failed to load library "${libraryName}" from "${libraryPaths.join(
", "
)}"\n` +
`Failed to load library "${libraryName}" from "${
libraryPaths.join(
", ",
)
}"\n` +
Object.entries(errors)
.map(([libraryPath, error]) => `\t=> ${libraryPath}: ${error.message}`)
.join("\n"),
new AggregateError(Object.values(errors))
new AggregateError(Object.values(errors)),
);
}

0 comments on commit d357f68

Please sign in to comment.