fix pruneEmptyDirectories for modules that are single files
fix typo
check if module is a directory in workspace before calling pruneEmptyDirectories