1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
theorangeone.net-legacy/plugins/utils.py

31 lines
666 B
Python

import subprocess # nosec
import logging
import os
logger = logging.getLogger(__file__)
NODE_PRODUCTION = os.environ.get('NODE_ENV') == 'production'
def flatten_list(array):
res = []
for el in array:
if isinstance(el, (list, tuple)):
res.extend(flatten_list(el))
continue
res.append(el)
return res
def run_command(detail, args, wrap=False):
if wrap:
run_command(detail, ['bash', '-c', ' '.join(flatten_list(args))])
else:
logger.info(detail + '...')
subprocess.run(flatten_list(args), check=True)
def node_bin(exec):
return os.path.join('node_modules', '.bin', exec)