handle missing config file

This commit is contained in:
Ruidy 2023-05-28 13:07:35 +02:00
parent 6974c67aee
commit f8bd649cf7
3 changed files with 10 additions and 2 deletions

View file

@ -1,4 +1,5 @@
{
"name": "VillaFleurie",
"templates": [
"index.html",
"t2-corail.html",

View file

@ -3,6 +3,7 @@ from typing import TypedDict
class Config(TypedDict):
name: str
templates: list[str]
outDir: str

View file

@ -1,3 +1,4 @@
import sys
from os import path
from loguru import logger
@ -7,8 +8,13 @@ from lib.engine import render
def main():
try:
config = load()
logger.info("🏁 Start building site")
except FileNotFoundError:
logger.error("The configuration file 'config.json' was not found. Please verify it exists at the root level")
sys.exit()
logger.info(f"🏁 Start building {config['name']}")
for template in config["templates"]:
logger.info(f"📃Render '{template}'")
with open(path.join(config["outDir"], template), "w") as f: