mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
expand env before run script
Signed-off-by: Frost Ming <mianghong@gmail.com>
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Environment variables are expanded correctly before running scripts on POSIX.
|
||||
+4
-2
@@ -2262,7 +2262,7 @@ def do_run_nt(script):
|
||||
|
||||
|
||||
def do_run_posix(script, command):
|
||||
command_path = system_which(script.command)
|
||||
command_path = system_which(os.path.expandvars(script.command))
|
||||
if not command_path:
|
||||
if project.has_script(command):
|
||||
click.echo(
|
||||
@@ -2287,7 +2287,9 @@ def do_run_posix(script, command):
|
||||
err=True,
|
||||
)
|
||||
sys.exit(1)
|
||||
os.execl(command_path, command_path, *script.args)
|
||||
os.execl(
|
||||
command_path, command_path, *[os.path.expandvars(arg) for arg in script.args]
|
||||
)
|
||||
|
||||
|
||||
def do_run(command, args, three=None, python=False, pypi_mirror=None):
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
|
||||
from pipenv.project import Project
|
||||
from pipenv.utils import temp_environ
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -27,6 +28,7 @@ printfoo = "python -c \"print('foo')\""
|
||||
notfoundscript = "randomthingtotally"
|
||||
appendscript = "cmd arg1"
|
||||
multicommand = "bash -c \"cd docs && make html\""
|
||||
scriptwithenv = "echo $HELLO"
|
||||
""")
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
@@ -52,3 +54,9 @@ multicommand = "bash -c \"cd docs && make html\""
|
||||
script = project.build_script('appendscript', ['a', 'b'])
|
||||
assert script.command == 'cmd'
|
||||
assert script.args == ['arg1', 'a', 'b']
|
||||
|
||||
with temp_environ():
|
||||
os.environ['HELLO'] = 'WORLD'
|
||||
c = p.pipenv("run scriptwithenv")
|
||||
assert c.ok
|
||||
assert c.out.strip() == "WORLD"
|
||||
|
||||
Reference in New Issue
Block a user