def find_executable(executable):
"""
Return the path to the given executable, or None if not found.
create_environment is used to augment PATH before searching
for the executable.
"""
env = create_environment()
for base in env.get('PATH', '').split(os.pathsep):
path = os.path.join(os.path.expanduser(base), executable)
# On Windows, if path does not have an extension, try .exe, .cmd, .bat
if sublime.platform() == 'windows' and not os.path.splitext(path)[1]:
for extension in ('.exe', '.cmd', '.bat'):
path_ext = path + extension
if can_exec(path_ext):
return path_ext
elif can_exec(path):
return path
return None
评论列表
文章目录