Skip to content

The design language that makes your AI harness better at design.

JavaScript

Fix: Use sync fs operations instead of fs/promises

Paul Bakaus13f4714b5dec
diff --git a/api/commands.js b/api/commands.js
index 86a66b087..db9c85759 100644
--- a/api/commands.js
+++ b/api/commands.js
@@ -1,4 +1,4 @@
-import { readdir, readFile } from "fs/promises";
+import { readdirSync, readFileSync } from "fs";
import { join, dirname } from "path";
import { fileURLToPath } from "url";
@@ -6,7 +6,7 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const PROJECT_ROOT = join(__dirname, "..");
-export default async function handler(request) {
+export default function handler(request) {
try {
const sourceDir = join(PROJECT_ROOT, "source");
const commandsDir = join(sourceDir, "commands");
@@ -14,12 +14,14 @@ export default async function handler(request) {
console.log("PROJECT_ROOT:", PROJECT_ROOT);
console.log("commandsDir:", commandsDir);
- const files = await readdir(commandsDir);
+ const files = readdirSync(commandsDir);
+ console.log("Files found:", files.length);
+
const commands = [];
for (const file of files) {
if (file.endsWith(".md")) {
- const content = await readFile(join(commandsDir, file), "utf-8");
+ const content = readFileSync(join(commandsDir, file), "utf-8");
const frontmatterMatch = content.match(/^---\n([\s\S]+?)\n---/);
if (frontmatterMatch) {
diff --git a/api/patterns.js b/api/patterns.js
index 7fec7e4d6..d797d8bbd 100644
--- a/api/patterns.js
+++ b/api/patterns.js
@@ -1,4 +1,4 @@
-import { readFile } from "fs/promises";
+import { readFileSync } from "fs";
import { join, dirname } from "path";
import { fileURLToPath } from "url";
@@ -6,14 +6,15 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const PROJECT_ROOT = join(__dirname, "..");
-export default async function handler(request) {
+export default function handler(request) {
try {
const sourceDir = join(PROJECT_ROOT, "source");
const filePath = join(sourceDir, "patterns.md");
console.log("Reading patterns from:", filePath);
- const content = await readFile(filePath, "utf-8");
+ const content = readFileSync(filePath, "utf-8");
+ console.log("File read, length:", content.length);
const frontmatterMatch = content.match(/^---\n([\s\S]+?)\n---/);
if (!frontmatterMatch) {