Coverage for /home/runner/work/coxbuild/coxbuild/src/coxbuild/extensions/shell/__init__.py: 0%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

19 statements  

1import platform 

2 

3from coxbuild.schema import group, run, task 

4 

5grouped = group("shell") 

6 

7 

8def whereCommand(name: str) -> list[str]: 

9 if "windows" in platform.system().lower(): 

10 res = run(["where.exe", name], pipe=True, fail=True) 

11 if res: 

12 return [f.strip() for f in res.stdout.splitlines() if f.strip()] 

13 else: 

14 return [] 

15 else: 

16 res = run(["whereis", name], pipe=True, fail=True) 

17 if res: 

18 return [f.strip() for f in res.stdout.split(":")[1].strip().split(" ") if f.strip()] 

19 else: 

20 return [] 

21 

22 

23def existCommand(name: str) -> bool: 

24 return len(whereCommand(name)) > 0 

25 

26 

27@grouped 

28@task 

29def execute(*args, **kwargs): 

30 run(*args, **kwargs)