private StringBuilder CreateLogEntries(JsGroupToProcess jsGroupToProcess, Uri outputUri, JsCrushedOutput crushedOutput, Stopwatch stopwatch) { outputUri = new Uri(jsGroupToProcess.PathProvider.ToAbsolute(outputUri.ToString()), UriKind.Absolute); var rootPath = jsGroupToProcess.PathProvider.GetAbsoluteUriDirectory("~/"); var output = new StringBuilder(); output.AppendFormat("{0} ({1} - {2} ms)\r\n", rootPath.MakeRelativeUri(outputUri), jsGroupToProcess.Group.Name, stopwatch.ElapsedMilliseconds); foreach (var jsFile in crushedOutput.FilesToWatch) { outputUri = new Uri(jsGroupToProcess.PathProvider.ToAbsolute(jsFile.FilePath), UriKind.Absolute); output.AppendFormat(" {0}\r\n", rootPath.MakeRelativeUri(outputUri)); } return output; }
/// <summary> /// Compress the js files and store them in the specified js file. /// </summary> /// <param name="outputFileInfo">The output path for the crushed js file.</param> /// <param name="jsRootUri"></param> /// <param name="files">The js files to be crushed.</param> /// <param name="directories"> </param> public virtual JsCrushedOutput ProcessGroup(FileInfo outputFileInfo, Uri jsRootUri, IEnumerable <JsFile> files, IEnumerable <JsDirectory> directories) { var filesToWatch = GetFilesToWatch(files, directories); var metaDataFiles = filesToWatch.Select(x => new FileInfo(x.FilePath)).Distinct().OrderBy(x => x.FullName); var isMetaDataFresh = FileMetaData.IsMetaDataFresh(outputFileInfo, metaDataFiles); if (!isMetaDataFresh) { var filesToProcess = filesToWatch .Select(jsFile => new JsFileProcessor(CoffeeCompilerPool, IcedCoffeeCompilerPool, LiveScriptCompilerPool, HoganCompilerPool, RetryableFileOpener, PathProvider, jsFile.FilePath, jsFile.CompressionType, jsRootUri)); var content = GetGroupContent(filesToProcess); RetryableFileWriter.SaveContentsToFile(content, outputFileInfo); FileMetaData.CreateMetaData(outputFileInfo, metaDataFiles); } var foldersToWatch = directories .Select(x => Talifun.FileWatcher.EnhancedFileSystemWatcherFactory.Instance .CreateEnhancedFileSystemWatcher(new Uri(PathProvider.MapPath(x.DirectoryPath)).LocalPath, x.IncludeFilter, x.ExcludeFilter, x.PollTime, x.IncludeSubDirectories)); var crushedOutput = new JsCrushedOutput { FoldersToWatch = foldersToWatch, FilesToWatch = filesToWatch }; return(crushedOutput); }
private StringBuilder CreateLogEntries(JsGroupToProcess jsGroupToProcess, Uri outputUri, JsCrushedOutput crushedOutput, Stopwatch stopwatch) { outputUri = new Uri(jsGroupToProcess.PathProvider.ToAbsolute(outputUri.ToString()), UriKind.Absolute); var rootPath = jsGroupToProcess.PathProvider.GetAbsoluteUriDirectory("~/"); var output = new StringBuilder(); output.AppendFormat("{0} ({1} - {2} ms)\r\n", rootPath.MakeRelativeUri(outputUri), jsGroupToProcess.Group.Name, stopwatch.ElapsedMilliseconds); foreach (var jsFile in crushedOutput.FilesToWatch) { outputUri = new Uri(jsGroupToProcess.PathProvider.ToAbsolute(jsFile.FilePath), UriKind.Absolute); output.AppendFormat(" {0}\r\n", rootPath.MakeRelativeUri(outputUri)); } return(output); }
/// <summary> /// Compress the js files and store them in the specified js file. /// </summary> /// <param name="outputFileInfo">The output path for the crushed js file.</param> /// <param name="jsRootUri"></param> /// <param name="files">The js files to be crushed.</param> /// <param name="directories"> </param> public virtual JsCrushedOutput ProcessGroup(FileInfo outputFileInfo, Uri jsRootUri, IEnumerable<JsFile> files, IEnumerable<JsDirectory> directories) { var filesToWatch = GetFilesToWatch(files, directories); var metaDataFiles = filesToWatch.Select(x => new FileInfo(x.FilePath)).Distinct().OrderBy(x => x.FullName); var isMetaDataFresh = FileMetaData.IsMetaDataFresh(outputFileInfo, metaDataFiles); if (!isMetaDataFresh) { var filesToProcess = filesToWatch .Select(jsFile => new JsFileProcessor(CoffeeCompilerPool, IcedCoffeeCompilerPool, LiveScriptCompilerPool, HoganCompilerPool, RetryableFileOpener, PathProvider, jsFile.FilePath, jsFile.CompressionType, jsRootUri)); var content = GetGroupContent(filesToProcess); RetryableFileWriter.SaveContentsToFile(content, outputFileInfo); FileMetaData.CreateMetaData(outputFileInfo, metaDataFiles); } var foldersToWatch = directories .Select(x => Talifun.FileWatcher.EnhancedFileSystemWatcherFactory.Instance .CreateEnhancedFileSystemWatcher(new Uri(PathProvider.MapPath(x.DirectoryPath)).LocalPath, x.IncludeFilter, x.ExcludeFilter, x.PollTime, x.IncludeSubDirectories)); var crushedOutput = new JsCrushedOutput { FoldersToWatch = foldersToWatch, FilesToWatch = filesToWatch }; return crushedOutput; }