Add Spinner to routes script and delete uwu file

This commit is contained in:
Joshua 2022-09-17 01:36:07 +02:00
parent 0c2db7c12b
commit b445f0dd98
2 changed files with 10 additions and 5 deletions

View file

@ -1,7 +1,11 @@
import { join, relative, ensureFileSync } from "../deps.ts"; import { join, relative, ensureFileSync, wait, S3 } from "../deps.ts";
const ROUTES_FILE = "routes.generated.ts"; const ROUTES_FILE = "routes.generated.ts";
const S3inner = wait({
text: `Generating ${ROUTES_FILE}...`,
spinner: "aesthetic"
})
interface PageRoute { interface PageRoute {
path: string; path: string;
route: string; route: string;
@ -40,6 +44,7 @@ async function readDir(dir: URL): Promise<PageRoute[]> {
else else
finalRoute = replaced.replace('/index', '/') finalRoute = replaced.replace('/index', '/')
S3inner.text = `Added ${finalRoute}`
routes.push({ routes.push({
route: finalRoute, route: finalRoute,
@ -83,14 +88,15 @@ async function write(folderwithroutes: string | URL, file: string | URL) {
if (import.meta.main) { if (import.meta.main) {
console.log(`Writing ${ROUTES_FILE}`)
try { try {
ensureFileSync(`./src/${ROUTES_FILE}`) ensureFileSync(`./src/${ROUTES_FILE}`)
await write('../src/routes', ROUTES_FILE) await write('../src/routes', ROUTES_FILE)
} catch (error) { } catch (error) {
console.error(error) console.error(error)
S3inner.fail()
Deno.exit(1) Deno.exit(1)
} }
console.log(`File written.`) S3inner.succeed("Routes generated.")
Deno.exit(0) Deno.exit(0)
} }

View file

@ -1 +0,0 @@
a