Created
April 9, 2024 02:28
-
-
Save xqm32/9aeb73c7a47cb6e0571415e614df0276 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { $ } from 'bun' | |
async function compile(code: string) { | |
const hasher = new Bun.CryptoHasher("sha256").update(code) | |
const destination = hasher.digest("hex").substring(0, 6) + ".c" | |
Bun.write(destination, code) | |
await $`gcc ${destination} -o ${destination}.out` | |
const output = await $`./${destination}.out`.text() | |
console.log(output) | |
} | |
const code = await Bun.file("main.c").text() | |
await compile(code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment