public static CompilerResult Run(Configuration.CompilerOptions options, string currentDirectory = default) { string scriptPath = Path.Combine(NodeJS.InstallationDirectory, "compiler.js"); if (!File.Exists(scriptPath)) { throw new FileNotFoundException($"Could not find file at '{scriptPath}'."); } long start = System.DateTime.Now.Ticks; string cwd = (Path.GetDirectoryName(options.ConfigurationFile) ?? currentDirectory); using (Process node = NodeJS.Execute($"/c node \"{scriptPath}\" {options.ToArgs()}", cwd)) { GetOutput(node.StandardOutput, cwd, out string[] sourceFiles, out string[] generatedFiles); return(new CompilerResult( (node.ExitCode == 0), GetErrors(node.StandardError).ToArray(), sourceFiles, generatedFiles, System.TimeSpan.FromTicks(System.DateTime.Now.Ticks - start) )); } }
private async void RunCompiler(string activeFile, IVsHierarchy hierarchy) { string projectFolder = Path.GetDirectoryName(hierarchy.ToProject()?.FullName); string configFile = Compiler.FindConfigurationFile(projectFolder); if (!File.Exists(configFile)) { return; } var options = new Configuration.CompilerOptions( configFile, ConfigurationPage.ShouldMinify, ConfigurationPage.ShouldGenerateSourceMaps ); CompilerResult result = await Compiler.RunAsync(options, projectFolder); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); ShowErrors(activeFile, hierarchy, result.Errors); _vsOutWindow.Writeline(GetSummary(result, projectFolder)); }
public static Task <CompilerResult> RunAsync(Configuration.CompilerOptions options, string currentDirectory = default) => Task.Run(() => { return(Run(options, currentDirectory)); });