File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,9 @@ def deploy(source: str, token: str) -> t.Deploy:
2121 # check if source is a directory
2222 if is_dir (source ):
2323 # walk directory tree and add files to list
24- file_dict ["files" ] = walk_dir_tree (source )
24+ file_dict ["files" ], root = walk_dir_tree (source )
2525 file_dict ["is_dir" ] = True
26- file_dict ["path" ] = source
26+ file_dict ["path" ] = root
2727 else :
2828 # add file to list
2929 file_dict ["files" ] = [source ]
Original file line number Diff line number Diff line change 66from . import types as t
77
88# walk path and return list of file paths
9- def walk_dir_tree (path : str ) -> List [str ]:
9+ def walk_dir_tree (path : str ) -> Tuple [ List [str ], str ]:
1010 file_list = []
11+ roots = []
1112 for root , dirs , files in os .walk (path ):
13+ roots .append (root )
1214 for file in files :
1315 file_list .append (os .path .join (root , file ))
14- return file_list
16+ return file_list , roots [ 0 ]
1517
1618
1719# check if file is a directory
@@ -24,6 +26,8 @@ def extract_file_name(file: str) -> str:
2426
2527
2628def extract_file_name_with_source (file : str , source : str ) -> str :
29+ if source .endswith ("/" ):
30+ source = source [: len (source ) - 1 ]
2731 base = source .split ("/" )[- 1 ]
2832 return base + file .split (base )[- 1 ]
2933
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ def test_deploy_file(self):
2121 def test_deploy_dir (self ):
2222 """test deploy function"""
2323 l = Lighthouse (os .environ ["LH_TOKEN" ])
24- res = l .deploy ("tests/testdir" )
24+ res = l .deploy ("tests/testdir/ " )
2525 self .assertNotEqual (res .get ("data" ), None , "data is None" )
2626 self .assertIsInstance (res .get ("data" ), str , "data is a string" )
2727 self .assertIn ("Hash" , res .get ("data" ), "Hash is in data" )
You can’t perform that action at this time.
0 commit comments