def _run(cmd, args=[], source="", cwd=None, env=None):
    if not type(args) is list:
        args = [args]

    module = settings_get("module", "")
    if module:
        args += ["--module", module]

    target = settings_get("target", "ES3")
    if target:
        args += ["--target", target]

    noImplicitAny = settings_get("noImplicitAny", False)
    if noImplicitAny:
        args += ["--noImplicitAny"]

    if sys.platform == "win32":
        args = [cmd] + args
        if sys.version_info[0] == 2:
            for i in range(len(args)):
                args[i] = args[i].encode(locale.getdefaultlocale()[1])
        proc = Popen(args, env=env, cwd=cwd, stdout=PIPE, stdin=PIPE, stderr=PIPE, shell=True)
        try:
            stat = proc.communicate(input=source)
        except:
            stat = proc.communicate(input=source.encode("utf8"))
        okay = proc.returncode == 0
        return {"okay": okay, "out": stat[0].decode(locale.getdefaultlocale()[1]), "err": stat[1].decode(locale.getdefaultlocale()[1])}
    else:
        if env is None:
            env = {"PATH": settings_get('binDir', '/usr/bin')}

        # adding custom PATHs from settings
        customEnv = settings_get('envPATH', "")
        if customEnv:
            env["PATH"] = env["PATH"]+":"+customEnv

        if source :
            command = [cmd] + args + [source]
        else:
            command = [cmd] + args
        print(command)
        proc = Popen(command, env=env, cwd=cwd, stdout=PIPE, stderr=PIPE)
        stat = proc.communicate()
        okay = proc.returncode == 0
        return {"okay": okay, "out": stat[0].decode('utf-8'), "err": stat[1].decode('utf-8')}
dataset/ETHPy150Open lavrton/sublime-better-typescript/TypeScript.py/_run/original