all repos — py-vite @ dd55790a7f2655dbddc6381f7d85444acd29bfea

the original vite, written in python

fix(make.py): apropriate message in case pages/ is empty
Anirudh icyph0x@protonmail.com
Sat, 14 Apr 2018 10:36:21 +0530
commit

dd55790a7f2655dbddc6381f7d85444acd29bfea

parent

68bec45daf522e817b4421b3f64df1729c927747

1 files changed, 17 insertions(+), 13 deletions(-)

jump to
M vite/make.pyvite/make.py

@@ -42,19 +42,23 @@

def main(): start = time.process_time() template_file = TEMPL_PATH + config.template - try: - for page in os.listdir(PAGES_PATH): - html_text = markdown_render(page) - html_file= os.path.splitext(os.path.join(BUILD_PATH, page))[0] - if not os.path.exists(html_file): - os.mkdir(html_file) - output = jinja_render(html_text, template_file) - with open(os.path.join(html_file, 'index.html'), 'w') as f: - f.write(output) - print(run('Rendered %s.' % (page))) - print(info('Done in %0.5fs.' % (time.process_time() - start))) - except jinja2.exceptions.TemplateNotFound: - print(bad('Error: specified template not found: %s' % (template_file))) + if not os.listdir(PAGES_PATH): + print(info(italic('pages') + ' directory is empty. Nothing to build.')) + sys.exit(1) + else: + try: + for page in os.listdir(PAGES_PATH): + html_text = markdown_render(page) + html_file= os.path.splitext(os.path.join(BUILD_PATH, page))[0] + if not os.path.exists(html_file): + os.mkdir(html_file) + output = jinja_render(html_text, template_file) + with open(os.path.join(html_file, 'index.html'), 'w') as f: + f.write(output) + print(run('Rendered %s.' % (page))) + print(info('Done in %0.5fs.' % (time.process_time() - start))) + except jinja2.exceptions.TemplateNotFound: + print(bad('Error: specified template not found: %s' % (template_file))) if __name__ == "__main__":