gale/scaffold.ts
2025-02-22 17:48:39 -05:00

20 lines
685 B
TypeScript

const hostedRoot = import.meta.resolve("./").slice(0, -1);
console.log("Checking", hostedRoot);
async function Download(file:string, processor = (text:string)=>text)
{
const pathHosted = hostedRoot + "/scaffold/" + file;
try
{
const fileContents = await fetch(pathHosted).then(resp=>resp.text());
await Deno.writeTextFile(file, processor(fileContents));
console.log(`Successfully downloaded ${file}`);
}
catch (error)
{
console.error(`Error downloading ${file}:`, error);
}
}
Download("deno.json", t=>t.replaceAll(`{HOSTED}`, hostedRoot));
Download("index.html", t=>t.replaceAll(`{HOSTED}`, hostedRoot));
Download("app.js");