all repos — py-vite @ 3b8124da265d369c4c87bd1093e6e6d326a82d1b

the original vite, written in python

feat(make.py): wayyy better handling of static/ dir
Anirudh icyph0x@pm.me
Mon, 16 Apr 2018 10:50:08 +0530
commit

3b8124da265d369c4c87bd1093e6e6d326a82d1b

parent

2ce9d2634d489da1eddd623683973cb478f09d22

1 files changed, 15 insertions(+), 11 deletions(-)

jump to
M make.pymake.py

@@ -10,6 +10,7 @@ import socketserver

from markdown2 import markdown_path from huepy import * +from distutils.dir_util import copy_tree desc = green('Script to build and serve Vite projects.') usage = lightblue('make.py') + ' [serve]'

@@ -70,7 +71,6 @@

def server(): handler = http.server.SimpleHTTPRequestHandler os.chdir(BUILD_PATH) - print(os.getcwd()) try: with socketserver.TCPServer(('', PORT), handler) as httpd: print(run(f'Serving the {italic("build")} directory at http://localhost:{PORT}'))

@@ -85,17 +85,21 @@

def main(): if args.serve: server() - start = time.process_time() - TEMPL_FILE = TEMPL_PATH + config.template - if not os.listdir(PAGES_PATH): - print(info(italic('pages') + ' directory is empty. Nothing to build.')) - sys.exit(1) else: - try: - html_gen() - print(good('Done in %0.5fs.' % (time.process_time() - start))) - except jinja2.exceptions.TemplateNotFound: - print(bad('Error: specified template not found: %s' % TEMPL_FILE)) + start = time.process_time() + TEMPL_FILE = TEMPL_PATH + config.template + if not os.listdir(PAGES_PATH): + print(info(italic('pages') + ' directory is empty. Nothing to build.')) + sys.exit(1) + else: + try: + html_gen() + if not os.path.exists(os.path.join(BUILD_PATH, 'static')): + os.mkdir(os.path.join(BUILD_PATH, 'static')) + copy_tree('static', os.path.join(BUILD_PATH, 'static')) + print(good('Done in %0.5fs.' % (time.process_time() - start))) + except jinja2.exceptions.TemplateNotFound: + print(bad('Error: specified template not found: %s' % TEMPL_FILE)) if __name__ == "__main__":