/// <summary>
        /// Generates final the output.
        /// </summary>
        /// <param name="args">The args.</param>
        public void FinalOutput(CompressFileGroupArgs args)
        {
            /* Allocate 128Kb*/
            var builder = new StringBuilder(8096 * 16);

            builder.AppendFormat("/** UTC Date: {0}", DateTime.UtcNow).AppendLine();
            builder.AppendLine(" *  Summary:");
            foreach (var file in args.Files)
            {
                builder.Append(" *      ").Append(file.FileName).Append(" => [Action: ").Append(
                    file.CompressorOutputStreamAction).Append("ed ],").Append("[Modified: ").Append(
                        file.FileInfo.LastWriteTimeUtc).Append(" ],").AppendLine();
            }

            builder.AppendLine(" */");

            foreach (var file in args.Files)
            {
                builder.AppendLine();

                builder.Append("/* ").Append(file.FileName).AppendLine(" */");

                builder.Append(file.Content);

                builder.AppendLine();
            }

            args.Output = builder.ToString();
        }
 /// <summary>
 /// The pipeline to remove vodca console log.
 /// </summary>
 /// <param name="args">The args.</param>
 public void JsPipelineVodcaConsoleLog(CompressFileGroupArgs args)
 {
     if (args.IsRelease)
     {
         foreach (var file in args.Files)
         {
             if (file.CompressorOutputStreamAction == CompressorOutputStreamAction.Compress)
             {
                 file.Content = JsVodcaConsoleLog.Replace(file.Content, string.Empty);
             }
         }
     }
 }
        /// <summary>
        /// Saves the file.
        /// </summary>
        /// <param name="args">The args.</param>
        public void SaveFile(CompressFileGroupArgs args)
        {
            string file = this.CurrentDirectory + args.XmlFileGroup.MinifiedFileName;
            string folder = Path.GetDirectoryName(file);

            /* ReSharper disable AssignNullToNotNullAttribute */

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            /* ReSharper restore AssignNullToNotNullAttribute */

            File.WriteAllText(file, args.Output);
        }
 /// <summary>
 /// The Css file compressing.
 /// </summary>
 /// <param name="args">The args.</param>
 public void CssFileCompress(CompressFileGroupArgs args)
 {
     if (args.IsRelease)
     {
         foreach (var file in args.Files)
         {
             if (file.CompressorOutputStreamAction == CompressorOutputStreamAction.Compress)
             {
                 file.Content = CssCompressor.Compress(
                     file.Content,
                     columnWidth: 120,
                     cssCompressionType: CssCompressionType.StockYuiCompressor,
                     removeComments: true);
             }
         }
     }
 }
 /// <summary>
 /// The JS file compressing.
 /// </summary>
 /// <param name="args">The args.</param>
 public void JsFileCompress(CompressFileGroupArgs args)
 {
     if (args.IsRelease)
     {
         foreach (var file in args.Files)
         {
             if (file.CompressorOutputStreamAction == CompressorOutputStreamAction.Compress)
             {
                 file.Content = JavaScriptCompressor.Compress(
                     file.Content,
                     isVerboseLogging: false,
                     isObfuscateJavascript: false,
                     preserveAllSemicolons: true,
                     disableOptimizations: true,
                     lineBreakPosition: 120);
             }
         }
     }
 }
Exemple #6
0
        /// <summary>
        /// Runs this instance.
        /// </summary>
        /// <returns>True if no errors</returns>
        public bool Run()
        {
            foreach (var filegroup in this.XmlSettings.FileGroups)
            {
                var args = new CompressFileGroupArgs(filegroup, this.CurrentDirectory, !this.XmlSettings.DebugVersion);

                switch (filegroup.GetCompressorAction())
                {
                    case CompressorAction.CssCompression:
                        this.CssPipeline(args);
                        break;
                    default:
                        this.JsPipeline(args);
                        break;
                }
            }

            return true;
        }