@chouquette/gleam
Version:
[Gleam](https://gleam.run) is a functional language that compiles to JavaScript! More information can be found [in the documentation](https://gleam.run/documentation/) directly, to get you started!
16 lines (13 loc) • 558 B
JavaScript
import * as fs from 'node:fs'
function endpoint(version, arch, platform) {
const base = 'https://github.com/gleam-lang/gleam/releases/download'
return `${base}/${version}/gleam-${version}-${arch}-${platform}.tar.gz`
}
export async function download({ tgzPath, version, arch, platform }) {
if (fs.existsSync(tgzPath)) return
const endpt = endpoint(version, arch, platform)
const res = await fetch(endpt)
if (!res.ok) throw new Error('Unreachable')
const tgz = await res.arrayBuffer()
await fs.promises.writeFile(tgzPath, Buffer.from(tgz))
}