bun-ui-tests 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/cli.ts +9 -4
  2. package/package.json +1 -1
  3. package/ui-runner.ts +11 -21
package/cli.ts CHANGED
@@ -60,11 +60,16 @@ async function buildFrontend() {
60
60
 
61
61
  async function checkBuildExists(): Promise<boolean> {
62
62
  const distPath = join(__dirname, "app", "dist", "index.html");
63
+ console.error(`Debug: __dirname is ${__dirname}`);
64
+ console.error(`Debug: import.meta.url is ${import.meta.url}`);
63
65
  try {
64
- await access(distPath);
65
- return true;
66
- } catch {
67
- console.error(`Debug: Checked path not found: ${distPath}`);
66
+ const exists = await Bun.file(distPath).exists();
67
+ if (!exists) {
68
+ console.error(`Debug: Bun.file.exists failed for: ${distPath}`);
69
+ }
70
+ return exists;
71
+ } catch (err) {
72
+ console.error(`Debug: Error checking path ${distPath}:`, err);
68
73
  return false;
69
74
  }
70
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bun-ui-tests",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "A beautiful UI for running Bun tests",
5
5
  "type": "module",
6
6
  "bin": {
package/ui-runner.ts CHANGED
@@ -14,7 +14,6 @@
14
14
  import { spawn } from "node:child_process";
15
15
  import { readdir, readFile, stat } from "node:fs/promises";
16
16
  import { join, relative, dirname } from "node:path";
17
- import { existsSync } from "node:fs";
18
17
 
19
18
  // Determina o diretório do executável ou script
20
19
  const getBaseDir = () => {
@@ -128,29 +127,20 @@ if (isDevMode) {
128
127
  }
129
128
 
130
129
  // 2. Arquivos Estáticos (Frontend)
131
- if (existsSync(distPath)) {
132
- let filePath = url.pathname === "/" ? "/index.html" : url.pathname;
133
- const fullPath = join(distPath, filePath);
134
-
135
- try {
136
- const file = Bun.file(fullPath);
137
- if (await file.exists()) {
138
- return new Response(file);
139
- }
140
-
141
- // Se não encontrou o arquivo e não é um asset (SPA fallback)
142
- if (!filePath.includes(".")) {
143
- const indexFile = Bun.file(join(distPath, "index.html"));
144
- return new Response(indexFile);
145
- }
146
- } catch (err) {
147
- console.error("Error serving file:", err);
130
+ const file = Bun.file(join(distPath, url.pathname === "/" ? "/index.html" : url.pathname));
131
+ if (await file.exists()) {
132
+ return new Response(file);
133
+ }
134
+
135
+ // SPA fallback
136
+ if (!url.pathname.includes(".")) {
137
+ const indexFile = Bun.file(join(distPath, "index.html"));
138
+ if (await indexFile.exists()) {
139
+ return new Response(indexFile);
148
140
  }
149
- } else {
150
- return new Response("Frontend build not found. Run 'buntestui build' first.", { status: 404 });
151
141
  }
152
142
 
153
- return new Response("Not found", { status: 404 });
143
+ return new Response("Frontend build not found.", { status: 404 });
154
144
  },
155
145
  websocket: websocketHandler
156
146
  });