Merge branch 'where-on-windows' of https://github.com/BYK/xonsh into BYK-where-on-windows

This commit is contained in:
Anthony Scopatz 2015-07-15 13:56:48 -07:00
commit 55a302aff5
2 changed files with 16 additions and 15 deletions

View file

@ -143,6 +143,8 @@ if ON_WINDOWS:
for alias in WINDOWS_CMD_ALIASES:
DEFAULT_ALIASES[alias] = ['cmd', '/c', alias]
DEFAULT_ALIASES['which'] = ['where']
elif ON_MAC:
DEFAULT_ALIASES['ls'] = ['ls', '-G']
else:

View file

@ -177,8 +177,10 @@ class Env(MutableMapping):
def locate_binary(name, cwd):
# StackOverflow for `where` tip: http://stackoverflow.com/a/304447/90297
locator = 'where' if ON_WINDOWS else 'which'
try:
binary_location = subprocess.check_output(['which', name],
binary_location = subprocess.check_output([locator, name],
cwd=cwd,
stderr=subprocess.PIPE,
universal_newlines=True)
@ -191,22 +193,19 @@ def locate_binary(name, cwd):
def ensure_git(func):
if ON_WINDOWS:
return func
else:
@wraps(func)
def wrapper(*args, **kwargs):
# Get cwd or bail
kwargs['cwd'] = kwargs.get('cwd', _get_cwd())
if kwargs['cwd'] is None:
return
@wraps(func)
def wrapper(*args, **kwargs):
# Get cwd or bail
kwargs['cwd'] = kwargs.get('cwd', _get_cwd())
if kwargs['cwd'] is None:
return
# step out completely if git is not installed
if locate_binary('git', kwargs['cwd']) is None:
return
# step out completely if git is not installed
if locate_binary('git', kwargs['cwd']) is None:
return
return func(*args, **kwargs)
return wrapper
return func(*args, **kwargs)
return wrapper
def ensure_hg(func):