fix: Check for undefined object when resolving URL

This commit is contained in:
Foster Hangdaan 2025-02-19 18:28:39 -05:00
parent 3d3c363b94
commit bfa12bee87
Signed by: foster
GPG key ID: E48D7F49A852F112

View file

@ -20,7 +20,14 @@ import { DeepPartial } from "lume/core/utils/object.ts";
import { Writer } from "lume/core/writer.ts"; import { Writer } from "lume/core/writer.ts";
import { fromFileUrl, join } from "@std/path"; import { fromFileUrl, join } from "@std/path";
const cwd = fromFileUrl(import.meta.resolve("./")); const specifier = "./";
const cwdUrl = await import.meta.resolve?.(specifier);
if (!cwdUrl) {
throw new Error(
`Attempted to resolve ${specifier} but got ${cwdUrl} instead.`,
);
}
const cwd = fromFileUrl(cwdUrl);
class TestWriter implements Writer { class TestWriter implements Writer {
savePages() { savePages() {