Skip to content

Commit

Permalink
thread compile_mjml
Browse files Browse the repository at this point in the history
  • Loading branch information
hrfee committed Mar 13, 2021
1 parent 03247dd commit 5892899
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
19 changes: 14 additions & 5 deletions scripts/compile_mjml.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import argparse
from pathlib import Path
from threading import Thread

parser = argparse.ArgumentParser()
parser.add_argument("-o", "--output", help="output directory for .html and .txt files")
Expand All @@ -15,15 +16,23 @@ def runcmd(cmd):
proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
return proc.communicate()

def compile(mjml: Path):
fname = mjml.with_suffix(".html")
runcmd(f"npx mjml {str(mjml)} -o {str(fname)}")
if fname.is_file():
print(f"Compiled {mjml.name}")

local_path = Path("mail")

threads = []

for mjml in [f for f in local_path.iterdir() if f.is_file() and "mjml" in f.suffix]:
print(f"Compiling {mjml.name}")
fname = mjml.with_suffix(".html")
runcmd(f"npx mjml {str(mjml)} -o {str(fname)}")
if fname.is_file():
print("Done.")
threads.append(Thread(target=compile, args=(mjml,)))

for thread in threads:
thread.start()
for thread in threads:
thread.join()

html = [f for f in local_path.iterdir() if f.is_file() and "html" in f.suffix]

Expand Down
2 changes: 2 additions & 0 deletions scripts/enumerate_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Since go doesn't order its json, this script adds ordered lists
# of section/setting names for the settings tab to use.
import json, argparse

parser = argparse.ArgumentParser()
Expand Down
2 changes: 2 additions & 0 deletions scripts/version.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash
# sets version environment variable for goreleaser to use
# scripts/version.sh goreleaser ...
JFA_GO_VERSION=$(git describe --exact-match HEAD 2> /dev/null || echo 'vgit')
JFA_GO_VERSION="$(echo $JFA_GO_VERSION | sed 's/v//g')" $@

0 comments on commit 5892899

Please sign in to comment.