blob: 8fcbb5ff7ec0878982552f16f04e2ad1be1d13e1 [file] [log] [blame]
#!/usr/bin/env python
# Copyright 2021 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import subprocess
import sys
import os
from dir_paths import node_dir
try:
old_sys_path = sys.path
sys.path = [node_dir] + sys.path
from node import GetBinaryPath as get_node_binary_path
finally:
sys.path = old_sys_path
tsc = os.path.join(node_dir, 'node_modules', 'typescript', 'lib', 'tsc.js')
def run_tsc_ignore_errors(args):
cmd = [get_node_binary_path(), tsc] + args
process = subprocess.Popen(cmd,
cwd=os.getcwd(),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
# Typecheck errors go in stdout, not stderr. If we see something in stderr, raise an error.
if len(stderr):
raise RuntimeError('tsc \'%s\' failed\n%s' % (' '.join(cmd), stderr))
return stdout
if __name__ == '__main__':
run_tsc_ignore_errors(sys.argv[1:])