Skip to content

Commit

Permalink
coala_html.py: Fix bug in copying angular package
Browse files Browse the repository at this point in the history
The current approach depends on `os.walk` to get the content
for a directory and then determines if the directory is empty.
The current approach is bugy in implementation and also the
approach isn't the best approach as it requires traversing
the directories recursively just to make sure that parent
directory is not empty.

The new approach with this commit, does the job by checking
for the existence of `index.html` in target directory. Since
we already know the structure of target directory which happens
to be a known angular package, we can just check if the `index.html`
exists in the target directory.

Fixes #83
  • Loading branch information
tushar-rishav committed Aug 5, 2016
1 parent c9201b4 commit 58f9d34
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion coalahtml/coala_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def main():

dir_path = create_dir(os.path.abspath(args.dir))

if len(list(os.walk(dir_path))) > 0: # pragma: no cover
if not os.path.isfile(os.path.join(dir_path, 'index.html')):
copy_files(get_file(Constants.COALA_HTML_BASE), dir_path)

if not args.noupdate:
Expand Down

0 comments on commit 58f9d34

Please sign in to comment.