private void ParseLoggingType() { if (string.IsNullOrEmpty(LoggingType)) { LogType = Yui.Compressor.LoggingType.Info; LogMessage("No logging argument defined. Defaulting to 'Info'."); return; } switch (LoggingType.ToLowerInvariant()) { case "none": LogType = Yui.Compressor.LoggingType.None; break; case "debug": LogType = Yui.Compressor.LoggingType.Debug; break; case "info": LogType = Yui.Compressor.LoggingType.Info; break; default: throw new ArgumentException("Logging Type: " + LoggingType + " is invalid.", "LoggingType"); } }
public override bool Execute() { var files = new List <string>(); if (RequireConfigs != null) { files = RequireConfigs.Select(r => r.GetMetadata("FullPath")).ToList(); } var entryPointOveride = string.Empty; if (EntryPointOverride != null) { entryPointOveride = EntryPointOverride.GetMetadata("FullPath"); } var LogLevel = LoggingType.ToLowerInvariant() == "debug" ? MessageImportance.High : MessageImportance.Normal; this.configProcessor = ConfigProcessorFactory.Create(AutoCompressor, ProjectPath, PackagePath, entryPointOveride, files, FileHelpers.ParseEncoding(EncodingType), Log, LogLevel); var bundles = new List <Bundle>(); try { bundles = this.configProcessor.ParseConfigs(); } catch (Exception ex) { var isDebugLogging = LoggingType.ToLower() == "debug"; Log.LogErrorFromException(ex, isDebugLogging, true, "RequireCompressorTask"); return(false); } if (bundles.Any()) { EnsureOutputDirectoriesExist(bundles); var compressor = new JavaScriptCompressor { Encoding = FileHelpers.ParseEncoding(EncodingType) }; foreach (var bundle in bundles) { if (!bundle.Files.Any()) { continue; } var taskEngine = new CompressorTaskEngine(new MsBuildLogAdapter(Log), compressor) { CompressionType = CompressionType, DeleteSourceFiles = false, EncodingType = EncodingType, LineBreakPosition = -1, LoggingType = LoggingType, OutputFile = bundle.Output, SourceFiles = bundle.Files.ToArray() }; taskEngine.Execute(); } } return(true); }