Skip to content

Commit

Permalink
Add debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
pastelsky committed Jan 3, 2024
1 parent d540ddc commit 73bfe3f
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions server/package/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,43 @@ export async function resolveDocsRequest({
docsPathDisk: string;
}
> {
if (!force && semver.valid(packageVersion)) {
if (force) {
const packageJSON = await resolvePackageJSON({
packageName,
packageVersion,
});

const docsPathDisk = getDocsPath({
packageName: packageName,
packageVersion: packageVersion,
});

if (fs.existsSync(path.join(docsPathDisk, "index.html")))
console.log("Force true, returning miss");
return {
type: "miss",
packageName: packageJSON.name,
packageVersion: packageJSON.version,
packageJSON,
docsPathDisk,
};
}

if (semver.valid(packageVersion)) {
const docsPathDisk = getDocsPath({
packageName: packageName,
packageVersion: packageVersion,
});

if (fs.existsSync(path.join(docsPathDisk, "index.html"))) {
console.log("Index.html exists at docsPathDisk", docsPathDisk, "HIT");

return {
type: "hit",
packageName,
packageVersion,
docsPathDisk,
};
}
}

const packageJSON = await resolvePackageJSON({
Expand All @@ -60,17 +84,12 @@ export async function resolveDocsRequest({
packageVersion: packageJSON.version,
});

if (force) {
return {
type: "miss",
packageName: packageJSON.name,
packageVersion: packageJSON.version,
packageJSON,
if (fs.existsSync(path.join(docsPathDisk, "index.html"))) {
console.log(
"Index.html exists at docsPathDisk after resolving version",
docsPathDisk,
};
}
);

if (fs.existsSync(path.join(docsPathDisk, "index.html"))) {
return {
type: "hit",
packageName: packageJSON.name,
Expand All @@ -79,6 +98,8 @@ export async function resolveDocsRequest({
};
}

console.log("No hits, hence miss", docsPathDisk);

return {
type: "miss",
packageName: packageJSON.name,
Expand Down

0 comments on commit 73bfe3f

Please sign in to comment.