public void Compile(String tsFile, TypeScriptNativeCompilerConfiguration configuration = null)
        {
            var conf = configuration ?? new TypeScriptNativeCompilerConfiguration()
            {
                CodePage       = null,
                RemoveComments = false,
                TargetVersion  = "ES5"
            };

            var psi = EnsureNativeCompiler(conf);

            psi.Arguments = "\"" + tsFile + "\"" + conf.BuildArguments();

            using (Process p = new Process()) {
                p.StartInfo = psi;

                p.Start();

                List <String> errors = new List <string>();
                List <String> infos  = new List <string>();

                p.ErrorDataReceived += (sender, e) => {
                    if (String.IsNullOrEmpty(e.Data))
                    {
                        return;
                    }

                    errors.Add(e.Data);
                };

                p.OutputDataReceived += (sender, e) => {
                    if (String.IsNullOrEmpty(e.Data))
                    {
                        return;
                    }

                    infos.Add(e.Data);
                };

                p.BeginOutputReadLine();
                p.BeginErrorReadLine();


                p.WaitForExit();

                if (p.ExitCode != 0)
                {
                    errors.AddRange(infos);
                    throw new TypeScriptNativeCompilerException(errors);
                }
            }
        }
        private ProcessStartInfo EnsureNativeCompiler(TypeScriptNativeCompilerConfiguration conf)
        {
            ProcessStartInfo psi = new ProcessStartInfo();

            psi.Arguments             = "-v";
            psi.WorkingDirectory      = conf.NativeBasePath;
            psi.RedirectStandardError = psi.RedirectStandardOutput = true;
            psi.FileName        = "tsc.exe";
            psi.UseShellExecute = false;

            using (Process p = new Process()) {
                p.StartInfo = psi;

                p.Start();

                Version v = null;

                p.OutputDataReceived += (sender, e) => {
                    if (String.IsNullOrEmpty(e.Data))
                    {
                        return;
                    }

                    String[] parts = e.Data.Split(' ');
                    Version.TryParse(parts.Last(), out v);
                };

                p.BeginErrorReadLine();
                p.BeginOutputReadLine();

                p.WaitForExit();

                if (null == v)
                {
                    throw new ArgumentException("Native TypeScript Compiler (tsc.exe) not found");
                }

                if (v < minVersion)
                {
                    throw new Exception(String.Format("Unsupported Compiler version {0} (min version: {1})", v, minVersion));
                }

                return(psi);
            }
        }