File tree Expand file tree Collapse file tree 1 file changed +3
-36
lines changed
Expand file tree Collapse file tree 1 file changed +3
-36
lines changed Original file line number Diff line number Diff line change 1- import os
2- import pathlib
3- import subprocess
4- import textwrap
5- from sys import exit
6- from typing import List , Optional
7-
8-
9- def run_command (command : List [str ], verbose : bool ) -> Optional [str ]:
10- try :
11- result = subprocess .run (
12- command ,
13- capture_output = True ,
14- text = True ,
15- check = True ,
16- )
17- if verbose :
18- print (result .stdout )
19- return result .stdout
20- except subprocess .CalledProcessError as e :
21- if verbose :
22- print (e .stderr )
23- exit (1 )
24-
25-
26- def create_or_update_file (
27- filepath : str | pathlib .Path , contents : Optional [str ] = None
28- ) -> None :
29- if os .path .dirname (filepath ) != "" :
30- os .makedirs (os .path .dirname (filepath ), exist_ok = True )
31- if contents is None :
32- open (filepath , "a" ).close ()
33- else :
34- with open (filepath , "w" ) as file :
35- file .write (textwrap .dedent (contents ).lstrip ())
1+ from exercise_utils .file import create_or_update_file
2+ from exercise_utils .git import add
363
374
385def setup (verbose : bool = False ):
@@ -49,4 +16,4 @@ def setup(verbose: bool = False):
4916 for member in crew :
5017 create_or_update_file (member )
5118
52- run_command ([ "git" , "add" , "." ], verbose )
19+ add ([ "." ], verbose )
You can’t perform that action at this time.
0 commit comments