mirror of
https://github.com/hrfee/jfa-go.git
synced 2025-02-01 15:30:11 +00:00
thread compile_mjml
This commit is contained in:
parent
03247ddef8
commit
5892899114
@ -3,6 +3,7 @@ import shutil
|
|||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from threading import Thread
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("-o", "--output", help="output directory for .html and .txt files")
|
parser.add_argument("-o", "--output", help="output directory for .html and .txt files")
|
||||||
@ -15,15 +16,23 @@ def runcmd(cmd):
|
|||||||
proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
|
proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
|
||||||
return proc.communicate()
|
return proc.communicate()
|
||||||
|
|
||||||
|
def compile(mjml: Path):
|
||||||
local_path = Path("mail")
|
|
||||||
|
|
||||||
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")
|
fname = mjml.with_suffix(".html")
|
||||||
runcmd(f"npx mjml {str(mjml)} -o {str(fname)}")
|
runcmd(f"npx mjml {str(mjml)} -o {str(fname)}")
|
||||||
if fname.is_file():
|
if fname.is_file():
|
||||||
print("Done.")
|
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]:
|
||||||
|
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]
|
html = [f for f in local_path.iterdir() if f.is_file() and "html" in f.suffix]
|
||||||
|
|
||||||
|
@ -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
|
import json, argparse
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/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=$(git describe --exact-match HEAD 2> /dev/null || echo 'vgit')
|
||||||
JFA_GO_VERSION="$(echo $JFA_GO_VERSION | sed 's/v//g')" $@
|
JFA_GO_VERSION="$(echo $JFA_GO_VERSION | sed 's/v//g')" $@
|
||||||
|
Loading…
Reference in New Issue
Block a user