mirror of
https://github.com/rjNemo/vf-site
synced 2026-06-06 01:16:38 +00:00
handle missing config file
This commit is contained in:
parent
6974c67aee
commit
f8bd649cf7
3 changed files with 10 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"name": "VillaFleurie",
|
||||||
"templates": [
|
"templates": [
|
||||||
"index.html",
|
"index.html",
|
||||||
"t2-corail.html",
|
"t2-corail.html",
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ from typing import TypedDict
|
||||||
|
|
||||||
|
|
||||||
class Config(TypedDict):
|
class Config(TypedDict):
|
||||||
|
name: str
|
||||||
templates: list[str]
|
templates: list[str]
|
||||||
outDir: str
|
outDir: str
|
||||||
|
|
||||||
|
|
|
||||||
10
lib/main.py
10
lib/main.py
|
|
@ -1,3 +1,4 @@
|
||||||
|
import sys
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
@ -7,8 +8,13 @@ from lib.engine import render
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
config = load()
|
try:
|
||||||
logger.info("🏁 Start building site")
|
config = load()
|
||||||
|
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"]:
|
for template in config["templates"]:
|
||||||
logger.info(f"📃Render '{template}'")
|
logger.info(f"📃Render '{template}'")
|
||||||
with open(path.join(config["outDir"], template), "w") as f:
|
with open(path.join(config["outDir"], template), "w") as f:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue