Files
klz-cables.com/.pnpm-store/v10/files/00/7a14854d0a8b510950dea19336378b0a801a6eff62300f7031d123e3012974fbbb8c64d0d0f1b053ae7bab52e6927b869717ac0eaa4ddfceed5fb1a000170a
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

40 lines
1.2 KiB
Plaintext

import fs from "fs";
import { ono } from "@jsdevtools/ono";
import * as url from "../util/url.js";
import { ResolverError } from "../util/errors.js";
import type { JSONSchema, ResolverOptions } from "../types/index.js";
import type { FileInfo } from "../types/index.js";
export default {
/**
* The order that this resolver will run, in relation to other resolvers.
*/
order: 100,
/**
* Determines whether this resolver can read a given file reference.
* Resolvers that return true will be tried, in order, until one successfully resolves the file.
* Resolvers that return false will not be given a chance to resolve the file.
*/
canRead(file: FileInfo) {
return url.isFileSystemPath(file.url);
},
/**
* Reads the given file and returns its raw contents as a Buffer.
*/
async read(file: FileInfo): Promise<Buffer> {
let path: string | undefined;
try {
path = url.toFileSystemPath(file.url);
} catch (err: any) {
throw new ResolverError(ono.uri(err, `Malformed URI: ${file.url}`), file.url);
}
try {
return await fs.promises.readFile(path);
} catch (err: any) {
throw new ResolverError(ono(err, `Error opening file "${path}"`), path);
}
},
} as ResolverOptions<JSONSchema>;