From b4e443a498fc1e59487caf0f4c82f22b248ea1c2 Mon Sep 17 00:00:00 2001 From: Nate Prewitt Date: Mon, 6 Feb 2017 13:25:50 -0700 Subject: [PATCH] return casing_changed --- pipenv/cli.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index d21e4575..358c5182 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -92,11 +92,18 @@ def ensure_pipfile(validate=True): # Create the pipfile if it doesn't exist. project.create_pipfile() + # TODO: Remove this check. Either fail on no Pipfile + # or fallback to an empty dict. # Validate the Pipfile's contents. if validate: # Ensure that Pipfile is using proper casing. p = project.parsed_pipfile - ensure_proper_casing(p) + changed = ensure_proper_casing(_pipfile=p) + + # Write changes out to disk. + if changed: + click.echo(crayons.yellow('Fixing package names in Pipfile...'), err=True) + project.write(p) def ensure_virtualenv(three=None, python=None): @@ -129,12 +136,7 @@ def ensure_proper_casing(_pipfile): casing_changed = proper_case_section(_pipfile.get('packages') or {}) casing_changed |= proper_case_section(_pipfile.get('dev-packages') or {}) - if casing_changed: - click.echo(crayons.yellow('Fixing package names in Pipfile...'), err=True) - - # Write pipfile out to disk. - project.write(_pipfile) - + return casing_changed def proper_case_section(section): """Verify proper casing is retrieved, when available, for each @@ -142,7 +144,6 @@ def proper_case_section(section): """ # Casing for section casing_changed = False - changed_values = [] # Replace each package with proper casing.