Files
klz-cables.com/.pnpm-store/v10/files/ae/84a2db04d42860f9e8b00b940f29d9647e53051834d586cdc1ac0b35937c2ff6d02bb443e5f6d36608964356bd6d6cf7807b4cbdfc7c221fc60f386ed95d17
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

50 lines
2.0 KiB
Plaintext

import fs from 'fs/promises';
import path from 'path';
async function pathOrFileExists(path) {
try {
await fs.access(path);
return true;
} catch {
return false;
}
}
/**
* Returns the path to the import map file. If the import map file is not found, it throws an error.
*/ export async function resolveImportMapFilePath({ adminRoute = '/admin', importMapFile, rootDir }) {
let importMapFilePath = undefined;
if (importMapFile?.length) {
if (!await pathOrFileExists(importMapFile)) {
try {
await fs.writeFile(importMapFile, '', {
flag: 'wx'
});
} catch (err) {
return new Error(`Could not find the import map file at ${importMapFile}${err instanceof Error && err?.message ? `: ${err.message}` : ''}`);
}
}
importMapFilePath = importMapFile;
} else {
const appLocation = path.resolve(rootDir, `app/(payload)${adminRoute}/`);
const srcAppLocation = path.resolve(rootDir, `src/app/(payload)${adminRoute}/`);
if (appLocation && await pathOrFileExists(appLocation)) {
importMapFilePath = path.resolve(appLocation, 'importMap.js');
if (!await pathOrFileExists(importMapFilePath)) {
await fs.writeFile(importMapFilePath, '', {
flag: 'wx'
});
}
} else if (srcAppLocation && await pathOrFileExists(srcAppLocation)) {
importMapFilePath = path.resolve(srcAppLocation, 'importMap.js');
if (!await pathOrFileExists(importMapFilePath)) {
await fs.writeFile(importMapFilePath, '', {
flag: 'wx'
});
}
} else {
return new Error(`Could not find Payload import map folder. Looked in ${appLocation} and ${srcAppLocation}`);
}
}
return importMapFilePath;
}
//# sourceMappingURL=resolveImportMapFilePath.js.map