Skip to content

Commit 1dfac30

Browse files
committed
chdir before generate
1 parent 9404e5d commit 1dfac30

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

index_generator/__main__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def app(args):
4040
print('See: index-generator --help')
4141
sys.exit(0)
4242
if args.no_recursive:
43-
generate_once(args.template, args.path, os.listdir(args.path), args.name, args.print, base=args.root, human=args.human)
43+
os.chdir(args.path)
44+
generate_once(args.template, '.', os.listdir('.'), args.name, args.print, base=args.root, human=args.human)
4445
else:
4546
generate_recursively(args.template, args.path, args.name, args.print, args.depth, base=args.root, human=args.human)
4647

@@ -85,7 +86,8 @@ def generate_once(template_dir, root, files, name, if_print, base='/', human=Fal
8586

8687

8788
def generate_recursively(template_dir, path, name, if_print, max_depth=0, base='/', human=False):
88-
for root, dirs, files in os.walk(path):
89+
os.chdir(path)
90+
for root, dirs, files in os.walk('.'):
8991
if max_depth != 0 and root.count(os.sep) >= max_depth:
9092
dirs.clear()
9193
continue

0 commit comments

Comments
 (0)