Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Commit

Permalink
add test-dependencies noting
Browse files Browse the repository at this point in the history
  • Loading branch information
eeue56 committed Mar 11, 2016
1 parent afa7d5c commit dc40f81
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Usage:

- `--dry` will only print the changes to happen, not write them to file
- `--quiet` will only print the final statement
- `--note` will add a `test-dependencies` field to the second file. Useful for tooling

```bash
python elm_deps_sync.py elm-package.json spec/elm/elm-package.json
Expand Down
20 changes: 17 additions & 3 deletions elm_deps_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import argparse


def sync_versions(top_level_file, spec_file, quiet=False, dry=False):
def sync_versions(top_level_file, spec_file, quiet=False, dry=False, note_test_deps=True):
""" first file should be the top level elm-package.json
second file should be the spec file
"""
Expand Down Expand Up @@ -34,7 +34,16 @@ def sync_versions(top_level_file, spec_file, quiet=False, dry=False):
other_package_version=spec['dependencies'][package_name])
)

if len(messages) > 0:
test_deps = {}

for (package_name, package_version) in spec['dependencies'].items():
if package_name not in top_level['dependencies']:
test_deps[package_name] = package_version

if note_test_deps:
spec['test-dependencies'] = test_deps

if len(messages) > 0 or note_test_deps:
print('{number} packages changed.'.format(number=len(messages)))

if not dry:
Expand All @@ -55,13 +64,18 @@ def main():

parser.add_argument('--quiet', '-q', action='store_true', help='don\'t print anything', default=False)
parser.add_argument('--dry', '-d', action='store_true', help='only print possible changes', default=False)
parser.add_argument('--note',
action='store_true',
help='add a test-dependencies field of things only found in the test',
default=False
)


parser.add_argument('top_level_file')
parser.add_argument('spec_file')
args = parser.parse_args()

sync_versions(args.top_level_file, args.spec_file, quiet=args.quiet, dry=args.dry)
sync_versions(args.top_level_file, args.spec_file, quiet=args.quiet, dry=args.dry, note_test_deps=args.note)


if __name__ == '__main__':
Expand Down

0 comments on commit dc40f81

Please sign in to comment.