From e3132e55b3ed67ebce7343ec66ed3960e3cd472f Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Mon, 13 Oct 2025 11:49:02 -0700 Subject: [PATCH] Refactor: Make code export handling more robust --- scripts/run-benchmark.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run-benchmark.js b/scripts/run-benchmark.js index f3a2019..d5f4ed2 100644 --- a/scripts/run-benchmark.js +++ b/scripts/run-benchmark.js @@ -20,7 +20,7 @@ const getLlmCode = async (prompt, model, functionName, temperature) => { const duration = (performance.now() - start) / 1000; const content = res.data.choices[0].message.content; const code = content.match(/```(?:javascript|js)?\n([\s\S]+?)\n```/)?.[1].trim() ?? content.trim(); - const finalCode = `${code.replace(/^export\s+(default\s+)?/, '')}\nexport default ${functionName};`; + const finalCode = `${code.replace(/export\s+default\s+.*$/m, '')}\nexport default ${functionName};`; return { code: finalCode, duration }; } catch (error) { console.error(`API Error for ${model}: ${error.message}`);