gale/scaffold.ts

19 lines
649 B
TypeScript
Raw Permalink Normal View History

2025-02-22 17:27:28 -05:00
const hostedRoot = import.meta.resolve("../").slice(0, -1);
async function Download(file:string, processor = (text:string)=>text)
2025-02-22 16:58:53 -05:00
{
2025-02-22 17:27:28 -05:00
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}`);
2025-02-22 16:58:53 -05:00
}
2025-02-22 17:27:28 -05:00
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");