forked from PacktPublishing/Angular-Cookbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_all.py
25 lines (20 loc) · 896 Bytes
/
install_all.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
import os
import subprocess
def find_matching_directories(root_dir):
matching_dirs = []
for root, dirs, _ in os.walk(root_dir):
if os.path.basename(root) == "start_here":
for dir_name in dirs:
matching_dirs.append(os.path.join(root, dir_name))
return matching_dirs
def execute_npm_install(directory):
try:
subprocess.run(['C:\\Program Files\\nodejs\\npm.cmd', 'install'], cwd=directory, check=True)
print(f"npm install completed in {directory}")
except subprocess.CalledProcessError as e:
print(f"npm install failed in {directory}: {e}")
if __name__ == "__main__":
root_directory = os.path.dirname(os.path.abspath(__file__))
matching_directories = find_matching_directories(root_directory)
for dir_path in matching_directories:
execute_npm_install(dir_path)