mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-07-23 04:52:58 +00:00
Centralise setup tool Commonlib selection
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { LIVESYNC_COMMONLIB_VERSION } from "./livesync-commonlib-version.ts";
|
||||
|
||||
function assert(condition: unknown, message: string): asserts condition {
|
||||
if (!condition) throw new Error(message);
|
||||
}
|
||||
|
||||
Deno.test("standalone utilities select one exact Commonlib registry version", async () => {
|
||||
const facadeURLs = [
|
||||
new URL("./setup/livesync-commonlib.ts", import.meta.url),
|
||||
new URL("./couchdb/livesync-commonlib.ts", import.meta.url),
|
||||
];
|
||||
const selectedVersions = (
|
||||
await Promise.all(facadeURLs.map((url) => Deno.readTextFile(url)))
|
||||
).flatMap((source) =>
|
||||
[...source.matchAll(
|
||||
/npm:@vrtmrz\/livesync-commonlib@([^/"]+)\//gu,
|
||||
)].map((match) => match[1])
|
||||
);
|
||||
|
||||
assert(selectedVersions.length > 0, "no Commonlib npm specifier was found");
|
||||
assert(
|
||||
selectedVersions.every((version) => version === LIVESYNC_COMMONLIB_VERSION),
|
||||
`Commonlib specifiers do not all select ${LIVESYNC_COMMONLIB_VERSION}: ${
|
||||
selectedVersions.join(", ")
|
||||
}`,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user