fix(bin/linja.in): recursively find all files in a pattern endswith /

Example: If you have an entry in .project file such as

    - theories/

It will remove all files under 'theories' directory from the project

related issue: leanprover/lean.js#3
This commit is contained in:
Soonho Kong 2015-07-29 16:40:34 -07:00
parent ed41a01a51
commit 8c1cd92add

View file

@ -551,9 +551,14 @@ def get_lean_names(lean_file, args, using_hlean):
item['clean'] = args.cache
return item
def recursive_glob(directory):
return [os.path.join(dirpath, f)
for dirpath, dirnames, files in os.walk(directory)
for f in fnmatch.filter(files, '*')]
def find_files(directory, pattern):
if "/" in pattern:
return glob.glob(os.path.join(directory, pattern))
if pattern.endswith("/"):
return recursive_glob(os.path.join(directory, pattern))
matches = []
for root, dirnames, filenames in os.walk(directory):
for filename in fnmatch.filter(filenames, pattern):