diff --git a/HISTORY.txt b/HISTORY.txt index 4e700f65..798cf398 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -1,6 +1,8 @@ 9.0.4: - Add --system flag to $ pipenv check. - Removal of package name suggestions. + - Support for [scripts] in Pipfile. + - Updated patched version of dotenv. 9.0.3: - v9.0.1. 9.0.2: diff --git a/Pipfile b/Pipfile index 06e781d3..7a7dcc7a 100644 --- a/Pipfile +++ b/Pipfile @@ -12,3 +12,8 @@ pytest-xdist = "*" [packages] "e1839a8" = {path = ".", editable = true} + + +[scripts] + +tests = "pytest tests" \ No newline at end of file diff --git a/pipenv/core.py b/pipenv/core.py index 96ed4173..a9c9b2b1 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -5,6 +5,7 @@ import codecs import os import sys import shutil +import shlex import signal import time import tempfile @@ -1974,6 +1975,10 @@ def do_run(command, args, three=None, python=False): load_dot_env() + # Script was found… + if command in project.scripts: + command = ' '.join(project.scripts[command]) + # Separate out things that were passed in as a string. _c = list(command.split()) command = _c.pop(0) @@ -1995,11 +2000,12 @@ def do_run(command, args, three=None, python=False): command_path = system_which(command) if not command_path: click.echo( - '{0}: the command {1} could not be found within {2}.' + '{0}: the command {1} could not be found within {2} or Pipfile\'s {3}.' ''.format( crayons.red('Error', bold=True), crayons.red(command), - crayons.normal('PATH', bold=True) + crayons.normal('PATH', bold=True), + crayons.normal('[scripts]', bold=True) ), err=True ) sys.exit(1) diff --git a/pipenv/project.py b/pipenv/project.py index 100b4376..47b3175a 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -3,6 +3,7 @@ import json import os import re import sys +import shlex import base64 import hashlib @@ -292,6 +293,15 @@ class Project(object): """A dictionary of the settings added to the Pipfile.""" return self.parsed_pipfile.get('pipenv', {}) + @property + def scripts(self): + scripts = self.parsed_pipfile.get('scripts', {}) + for (k, v) in scripts.items(): + scripts[k] = shlex.split(v, posix=True) + + return scripts + + def update_settings(self, d): settings = self.settings