-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunProject.py
64 lines (48 loc) · 1.64 KB
/
runProject.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
import subprocess
apps = [
{'name': "Login app (🐈😺)", 'path': 'login-page-animated-cat'},
{'name': 'Pizza order', 'path': 'pizza-order-app'},
{'name': "MCQ test 🥴", 'path': 'mcq-test'},
{'name': 'Nav demo with state', 'path': 'nav-demo-app-state'},
{'name': 'Nav demo with router', 'path': 'nav-demo-app-router'},
]
def execute_app(app):
try:
# Change directory to the app path
os.chdir(app['path'])
# Start the command in a hidden command prompt window
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
subprocess.Popen((app['execute'] if 'execute' in app else 'npm run dev'), shell=True, startupinfo=startupinfo)
os.chdir('../')
print(f'🚀 {app["name"]} started...')
except Exception as e:
print("Error: ", e)
def cls():
os.system('cls')
app_choice = None
while True:
cls()
for i, app in enumerate(apps):
print(f'''{i+1}. {app['name']}''')
print(f'{len(apps)+1}. All')
try:
app_choice = int(input("Which Project/App : "))
except:
print("Invalid input")
continue
if not input("Do you want to Edit?(y = Yes, Enter = No):").lower() == "y":
break
def execute(app):
os.system(f"cd {app['path']} && {(app['execute'] if 'execute' in app else 'npm run dev')}")
pass
def executeAll():
for app in apps:
execute_app(app)
if not app_choice:
exit("Invalid choice")
if app_choice == len(apps)+1:
executeAll()
else:
execute(apps[app_choice-1])