Fix script command and testing:

- Use string format compatible with python 2.7
- Use `click.echo`, not `print`
- The command is `pipenv script` not `pipenv scripts`
- The stanza label in Pipfile is `[scripts]`, not `[script]`
- The default when getting from the pipfile should be dict, not a list
This commit is contained in:
Glen Smith
2020-08-28 15:14:35 -06:00
parent 4e3baf5713
commit 622d119ea6
2 changed files with 6 additions and 5 deletions
+5 -4
View File
@@ -727,12 +727,13 @@ def script(state, args):
"""Lists scripts in current environment config."""
from ..core import project
if not project:
print("project not found")
echo(u"project not found", err=True)
exit(1)
scripts = project.parsed_pipfile.get('scripts', [])
print("command\tscript")
scripts = project.parsed_pipfile.get('scripts', {})
rpt = u"command\tscript\n"
for k, v in scripts.items():
print(f"{k}\t{v}")
rpt += u"{0}\t{1}".format(k, v)
echo(rpt)
return
+1 -1
View File
@@ -202,7 +202,7 @@ def test_scripts(PipenvInstance):
with PipenvInstance() as p:
with open(p.pipfile_path, "w") as f:
contents = """
[script]
[scripts]
pyver = "which python"
""".strip()
f.write(contents)