void ExecuteWithNode(TypeScriptProject project, TypeScriptProjectConfiguration conf, IProgressMonitor monitor, ExecutionContext context) { if (console != null) console.Dispose (); var exe = GetNodePath (); bool pause = conf.PauseConsoleOutput; monitor.Log.WriteLine ("Running project..."); if (conf.ExternalConsole) console = context.ExternalConsoleFactory.CreateConsole (!pause); else console = context.ConsoleFactory.CreateConsole (!pause); AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor (monitor); try { var cmd = CreateExecutionCommand (conf); if (!context.ExecutionHandler.CanExecute (cmd)) { monitor.ReportError ("Cannot execute \"" + exe + "\". The selected execution mode is not supported for TypeScript projects.", null); return; } IProcessAsyncOperation op = context.ExecutionHandler.Execute (cmd, console); operationMonitor.AddOperation (op); op.WaitForCompleted (); monitor.Log.WriteLine ("The operation exited with code: {0}", op.ExitCode); } catch (Exception ex) { monitor.ReportError ("Cannot execute \"" + exe + "\"", ex); } finally { operationMonitor.Dispose (); console.Dispose (); } }
public override SolutionItemConfiguration CreateConfiguration(string name) { TypeScriptProjectConfiguration conf = new TypeScriptProjectConfiguration (); conf.Name = name; return conf; }
ExecutionCommand CreateExecutionCommand(TypeScriptProjectConfiguration conf) { NodeExecutionCommand cmd = new NodeExecutionCommand (GetNodePath (), GetTargetJavascriptFilePath ()); cmd.AdditionalArguments = conf.CommandLineParameters; cmd.WorkingDirectory = Path.GetDirectoryName (GetTargetJavascriptFilePath ()); return cmd; }
public BuildResult CompileWithTsc(TypeScriptProject project, TypeScriptProjectConfiguration configuration, IProgressMonitor monitor) { string exe = PropertyService.Get<string> ("TypeScriptBinding.TscLocation"); exe = string.IsNullOrEmpty (exe) ? FindToolPath ("tsc") : exe; var outfile = project.GetTargetJavascriptFilePath (); var outdir = Path.GetDirectoryName (outfile); if (!Directory.Exists (outdir)) Directory.CreateDirectory (outdir); var argList = new List<string> (); argList.Add ("--out"); argList.Add (outfile.FirstOrDefault () == '"' ? '"' + outfile + '"' : outfile); if (configuration.DebugMode) { argList.Add ("-c"); argList.Add ("--sourcemap"); } if (project.AdditionalArguments != "") argList.Add (project.AdditionalArguments); if (configuration.AdditionalArguments != "") argList.Add (configuration.AdditionalArguments); foreach (var fp in project.Files.Where (pf => pf.Subtype == Subtype.Code && pf.BuildAction == "Compile")) argList.Add (fp.FilePath.FullPath); var args = String.Join (" ", argList.ToArray ()); var stdOutErr = new StringWriter (); int exitCode = RunTool (exe, args, project.BaseDirectory, monitor, stdOutErr); BuildResult result = ParseOutput (project, stdOutErr.ToString ()); if (result.CompilerOutput.Trim ().Length != 0) monitor.Log.WriteLine (result.CompilerOutput); if (result.ErrorCount == 0 && exitCode != 0) { string errorMessage = stdOutErr.ToString (); if (!string.IsNullOrEmpty (errorMessage)) result.AddError (errorMessage); else result.AddError ("Build failed. Go to \"Build Output\" for more information"); } return result; }