fix(cli): narrow codebases to bun

This commit is contained in:
Ruben Fiszel
2024-05-09 19:30:15 +02:00
parent cedc1027c4
commit 47862e6322
2 changed files with 22 additions and 6 deletions
+5 -2
View File
@@ -139,9 +139,13 @@ export async function handleFile(
.substring(0, path.indexOf("."))
.replaceAll("\\", "/");
const codebase = findCodebase(path, codebases);
const language = inferContentTypeFromFilePath(path, opts?.defaultTs);
const codebase =
language == "bun" ? findCodebase(path, codebases) : undefined;
let bundleContent: string | undefined = undefined;
if (codebase) {
const esbuild = await import("npm:esbuild");
log.info(`Starting building the bundle for ${path}`);
@@ -168,7 +172,6 @@ export async function handleFile(
globalDeps
)
)?.payload;
const language = inferContentTypeFromFilePath(path, opts?.defaultTs);
const workspaceId = workspace.workspaceId;
+17 -4
View File
@@ -89,13 +89,26 @@ export function findCodebase(
}
}
}
function addCodebaseDigestIfRelevant(
async function addCodebaseDigestIfRelevant(
path: string,
content: string,
codebases: SyncCodebase[]
): string {
): Promise<string> {
const isScript = path.endsWith(".script.yaml");
if (isScript) {
if (!isScript) {
return content;
}
let isTs = true;
try {
await Deno.stat(path.replace(".script.yaml", ".ts"));
} catch {
isTs = false;
}
if (!isTs) {
return content;
}
log.info(`isScript: ${isScript}, isTs: ${isTs}; ${path}`);
if (isTs) {
const c = findCodebase(path, codebases);
if (c) {
const parsed: any = yamlParse(content);
@@ -144,7 +157,7 @@ export async function FSFSElement(
async getContentText(): Promise<string> {
const content = await Deno.readTextFile(localP);
return addCodebaseDigestIfRelevant(localP, content, codebases);
return await addCodebaseDigestIfRelevant(localP, content, codebases);
},
};
}