Add Spinner to routes script and delete uwu file
This commit is contained in:
parent
0c2db7c12b
commit
b445f0dd98
2 changed files with 10 additions and 5 deletions
|
@ -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 S3inner = wait({
|
||||
text: `Generating ${ROUTES_FILE}...`,
|
||||
spinner: "aesthetic"
|
||||
})
|
||||
|
||||
interface PageRoute {
|
||||
path: string;
|
||||
route: string;
|
||||
|
@ -40,6 +44,7 @@ async function readDir(dir: URL): Promise<PageRoute[]> {
|
|||
else
|
||||
finalRoute = replaced.replace('/index', '/')
|
||||
|
||||
S3inner.text = `Added ${finalRoute}`
|
||||
|
||||
routes.push({
|
||||
route: finalRoute,
|
||||
|
@ -83,14 +88,15 @@ async function write(folderwithroutes: string | URL, file: string | URL) {
|
|||
|
||||
|
||||
if (import.meta.main) {
|
||||
console.log(`Writing ${ROUTES_FILE}`)
|
||||
|
||||
try {
|
||||
ensureFileSync(`./src/${ROUTES_FILE}`)
|
||||
await write('../src/routes', ROUTES_FILE)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
S3inner.fail()
|
||||
Deno.exit(1)
|
||||
}
|
||||
console.log(`File written.`)
|
||||
S3inner.succeed("Routes generated.")
|
||||
Deno.exit(0)
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
a
|
Loading…
Add table
Reference in a new issue