use npx to avoid looking for node_modules, get rid of useless

get_node_deps

makefile works without interaction by default now.
This commit is contained in:
Harvey Tindall
2020-10-18 00:57:53 +01:00
parent 8672d7dc18
commit 8e6cf799cd
9 changed files with 43 additions and 129 deletions
+1 -24
View File
@@ -1,15 +1,8 @@
import subprocess
import shutil
import os
import argparse
from pathlib import Path
parser = argparse.ArgumentParser()
parser.add_argument(
"-y", "--yes", help="use assumed node bin directory.", action="store_true"
)
def runcmd(cmd):
if os.name == "nt":
@@ -19,27 +12,11 @@ def runcmd(cmd):
local_path = Path(__file__).resolve().parent
out = runcmd("npm bin")
try:
node_bin = Path(out[0].decode("utf-8").rstrip())
except:
node_bin = Path(out.decode("utf-8").rstrip())
args = parser.parse_args()
if not args.yes:
print(f'assuming npm bin directory "{node_bin}". Is this correct?')
if input("[yY/nN]: ").lower() == "n":
node_bin = local_path.parent / "node_modules" / ".bin"
print(f'this? "{node_bin}"')
if input("[yY/nN]: ").lower() == "n":
node_bin = input("input bin directory: ")
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'{str(node_bin / "mjml")} {str(mjml)} -o {str(fname)}')
runcmd(f"npx mjml {str(mjml)} -o {str(fname)}")
if fname.is_file():
print("Done.")