diff --git a/website/app/api/run-code/route.ts b/website/app/api/run-code/route.ts index ec44d3a..ed9687e 100644 --- a/website/app/api/run-code/route.ts +++ b/website/app/api/run-code/route.ts @@ -12,9 +12,23 @@ export async function POST(req: Request) { output: 'Error: Cannot run code with dakhel call', }); } + await setupDarijaScript(); return Response.json(await runCodeWithInput(code)); } +async function setupDarijaScript() { + try { + const { stderr } = await execute('darijascript --version'); + if (stderr) { + throw new Error(stderr); + } + } catch (error) { + await execute( + 'wget https://github.com/rabraghib/darijascript/releases/latest/download/darijascript-bin -O /usr/local/bin/darijascript && chmod +x /usr/local/bin/darijascript' + ); + } +} + async function runCodeWithInput(code: string) { try { const codeFilePath = temporaryFile({ extension: 'ds' }); diff --git a/website/install.sh b/website/install.sh deleted file mode 100644 index b34c242..0000000 --- a/website/install.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -wget https://github.com/rabraghib/darijascript/releases/latest/download/darijascript-bin -O /usr/local/bin/darijascript - -chmod +x /usr/local/bin/darijascript diff --git a/website/vercel.json b/website/vercel.json deleted file mode 100644 index 95457bb..0000000 --- a/website/vercel.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "installCommand": "chmod +x ./install.sh && ./install.sh && npm install" -}