public void CompileToTypeScriptAndRun()
 {
     var c = new TypeScriptCompilerUtility().CompileToJavaScript(GetTestScriptFile("Test01.ts"), JavaScriptEngine.NodeJS);
     Assert.IsTrue(c.Succeeded);
     var r = new JavaScriptRunner().Run(c.OutputFileName, JavaScriptEngine.NodeJS);
     Assert.IsTrue(r.Succeeded);
     Assert.AreEqual(Test01_Ouptut.Replace("\r",""), r.Output);
 }
Example #2
0
        public static void Main(string[] args)
        {
            Print("jsCompilerUtility");
            var exitCode = 0;
            var cmdLine  = new CommandLine(args);

            if (cmdLine.Exist("-typescript"))
            {
                var tsFile = cmdLine.Arguments("-typescript");
                Print("Compiling to JavaScript TypeScript file:{0}".format(tsFile));
                var c = new TypeScriptCompilerUtility().CompileToJavaScript(tsFile, JavaScriptEngine.NodeJS);
                if (c.Succeeded)
                {
                    if (cmdLine.Exist("-run"))
                    {
                        Print("Running file:{0}".format(c.OutputFileName));
                        var x = new JavaScriptRunner().Run(c.OutputFileName, JavaScriptEngine.NodeJS);
                        if (x.Succeeded)
                        {
                            Print(x.Output);
                        }
                        else
                        {
                            Print("{0} execution failed\n{1}".format(c.OutputFileName, x.Output + x.ErrorOutput));
                        }
                    }
                }
                else
                {
                    Print(c.ConsoleOutput);
                    exitCode = 1;
                }
            }
            if (cmdLine.Exist("-pause"))
            {
                Console.WriteLine("Press any key to continue");
                Console.ReadKey();
            }
            System.Environment.ExitCode = exitCode;
        }
 public static void Main(string[] args)
 {
     Print("jsCompilerUtility");
     var exitCode = 0;
     var cmdLine = new CommandLine(args);
     if (cmdLine.Exist("-typescript"))
     {
         var tsFile = cmdLine.Arguments("-typescript");
         Print("Compiling to JavaScript TypeScript file:{0}".format(tsFile));
         var c = new TypeScriptCompilerUtility().CompileToJavaScript(tsFile, JavaScriptEngine.NodeJS);
         if (c.Succeeded)
         {
             if (cmdLine.Exist("-run"))
             {
                 Print("Running file:{0}".format(c.OutputFileName));
                 var x = new JavaScriptRunner().Run(c.OutputFileName, JavaScriptEngine.NodeJS);
                 if (x.Succeeded)
                 {
                     Print(x.Output);
                 }
                 else
                 {
                     Print("{0} execution failed\n{1}".format(c.OutputFileName, x.Output + x.ErrorOutput));
                 }
             }
         }
         else
         {
             Print(c.ConsoleOutput);
             exitCode = 1;
         }
     }
     if (cmdLine.Exist("-pause"))
     {
         Console.WriteLine("Press any key to continue");
         Console.ReadKey();
     }
     System.Environment.ExitCode = exitCode;
 }