Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions dotenv/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
import re
import sys
from subprocess import Popen, PIPE, STDOUT
from subprocess import Popen
import warnings
from collections import OrderedDict

Expand Down Expand Up @@ -287,19 +287,10 @@ def run_command(command, env):
cmd_env.update(env)

p = Popen(command,
stdin=PIPE,
stdout=PIPE,
stderr=STDOUT,
universal_newlines=True,
bufsize=0,
shell=False,
env=cmd_env)
try:
out, _ = p.communicate()
print(out)
except Exception:
warnings.warn('An error occured, running the command:')
out, _ = p.communicate()
warnings.warn(out)
_, _ = p.communicate()

return p.returncode
12 changes: 8 additions & 4 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,14 @@ def test_run(cli):
assert result == 'BAR'


def test_run_with_other_env(cli, dotenv_file):
cli.invoke(dotenv_cli, ['--file', dotenv_file, 'set', 'FOO', "BAR"])
result = cli.invoke(dotenv_cli, ['--file', dotenv_file, 'run', 'printenv', 'FOO'])
assert result.output.strip() == 'BAR'
def test_run_with_other_env(cli):
DOTENV_FILE = 'dotenv'
with cli.isolated_filesystem():
sh.cd(here)
sh.touch(DOTENV_FILE)
sh.dotenv('--file', DOTENV_FILE, 'set', 'FOO', 'BAR')
result = sh.dotenv('--file', DOTENV_FILE, 'run', 'printenv', 'FOO').strip()
assert result == 'BAR'


def test_run_without_cmd(cli):
Expand Down