Last active
May 16, 2018 21:31
-
-
Save derekedelaney/45f4d6d7fcf9a527a049ecb88f6a52c2 to your computer and use it in GitHub Desktop.
Prints the directory if there is a missing spec file for javascript. Use `--exclusions` to ignore keywords in a file name.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import argparse | |
def no_spec_file(rootdir, exclusions): | |
for subdir, dirs, files in os.walk(rootdir): | |
for file in files: | |
split_file = os.path.join(subdir, file).split('.') | |
if len(split_file) == 2 and split_file[1] == 'js': | |
spec_file = split_file[0]+'.spec.js' | |
if not os.path.isfile(spec_file) and not any(word in file for word in exclusions): | |
print os.path.join(subdir, file) | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument("root_dir", help="Name of the root directory") | |
parser.add_argument("--exclusions", help="A list of words to exclude from the file name", nargs="*", default=[]) | |
args = parser.parse_args() | |
if not no_spec_file(args.root_dir, args.exclusions): | |
sys.exit(1) | |
if __name__ == "__main__": | |
main() |
Ignore keywords with --exclusions
python /path/to/no_spec_file.py /path/to/src/folder/to/check --exclusions settings constants Constants
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run using
python /path/to/no_spec_file.py /path/to/src/folder/to/check