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

32 lines
666 B
Python
Raw Normal View History

2017-01-12 09:21:04 +00:00
import subprocess # nosec
2017-01-12 09:00:01 +00:00
import logging
import os
logger = logging.getLogger(__file__)
2017-01-13 19:38:29 +00:00
NODE_PRODUCTION = os.environ.get('NODE_ENV') == 'production'
2017-01-12 09:00:01 +00:00
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:
2017-01-13 19:38:29 +00:00
run_command(detail, ['bash', '-c', ' '.join(flatten_list(args))])
2017-01-12 09:00:01 +00:00
else:
logger.info(detail + '...')
subprocess.run(flatten_list(args), check=True)
def node_bin(exec):
return os.path.join('node_modules', '.bin', exec)