

def run(self, *args, **kwargs):
    compile_dir = settings_get('compileDir')
    source_file = self.view.file_name()
    source_dir = os.path.normcase(os.path.dirname(source_file))
    compile_paths = settings_get('compilePaths')
    sourcemaps = settings_get('sourceMaps', True)
    args = [source_file]
    if sourcemaps:
        args = (['--sourcemap'] + args)
    if isinstance(compile_paths, dict):
        appendix_len = None
        for key_path in compile_paths:
            norm_path = os.path.normcase(key_path)
            appendix = os.path.relpath(source_dir, norm_path)
            if ((not appendix.startswith('..')) and ((appendix_len is None) or (len(appendix) < appendix_len))):
                appendix_len = len(appendix)
                compile_dir = compile_paths[key_path]
                if (not os.path.isabs(compile_dir)):
                    compile_dir = os.path.join(norm_path, compile_dir)
                compile_dir = os.path.join(compile_dir, appendix)
    if (compile_dir and isinstance(compile_dir, str)):
        if (not os.path.isabs(compile_dir)):
            compile_dir = os.path.join(source_dir, compile_dir)
        print(('Compile to:' + compile_dir))
        if (not os.path.exists(compile_dir)):
            os.makedirs(compile_dir)
            print(('Compile dir did not exist, created folder: ' + compile_dir))
        (folder, file_nm) = os.path.split(source_file)
        args = (['--outDir', compile_dir] + args)
    else:
        compile_dir = source_dir
        print('Compile to same directory')
    if sourcemaps:
        cwd = source_dir
    else:
        cwd = None
    later = (lambda : sublime.status_message('Compiling'))
    sublime.set_timeout(later, 300)
    run('tsc', args, cwd=cwd, callback=(lambda res: self.on_done(res)))

dataset/ETHPy150Open lavrton/sublime-better-typescript/TypeScript.py CompileCodeCommand.run/original