45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
#!/usr/bin/python
|
|
from os import chdir, system, path
|
|
from sys import argv
|
|
from subprocess import run, PIPE
|
|
from multiprocessing import Process
|
|
|
|
apps = ['core', 'api', 'www']
|
|
commands = {
|
|
'build': 'npm run build',
|
|
'install': 'npm ci',
|
|
'prettier': 'npm run prettier'
|
|
}
|
|
|
|
|
|
def print_commands():
|
|
print('Available commands:', [c for c in commands])
|
|
|
|
|
|
def run_command_in_app(app: str, command: str):
|
|
chdir(app)
|
|
result = run(command.split(' '), stdout=PIPE, stderr=PIPE, text=True)
|
|
|
|
status = 'DONE' if result.returncode == 0 else 'ERROR'
|
|
print('%s:\t%s' % (app, status))
|
|
if status == 'ERROR':
|
|
print(result.stdout, result.stderr)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if len(argv) < 2:
|
|
print_commands()
|
|
exit()
|
|
|
|
cmd = argv[1]
|
|
if cmd not in commands:
|
|
print('Command \'%s\' not available' % cmd)
|
|
print_commands()
|
|
exit()
|
|
|
|
chdir(path.join(path.dirname(path.realpath(__file__)), '..'))
|
|
|
|
print('Running \'%s\' on %d apps: %s' % (commands[cmd], len(apps), apps))
|
|
for app in apps:
|
|
Process(target=run_command_in_app, args=(app, commands[cmd])).start()
|