Skip to content

Commit

Permalink
Preserving file integrity if minify:false
Browse files Browse the repository at this point in the history
Ref: #377
  • Loading branch information
rockstardev committed Mar 23, 2019
1 parent 46134c8 commit 092e460
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/BundlerMinifier.Core/Bundle/BundleHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ public static void ProcessBundle(string baseFolder, Bundle bundle)
StringBuilder sb = new StringBuilder();
List<string> inputFiles = bundle.GetAbsoluteInputFiles();

foreach (string input in inputFiles)
for (int i = 0; i < inputFiles.Count; i++)
{
var input = inputFiles[i];

string file = Path.Combine(baseFolder, input);

if (File.Exists(file))
Expand All @@ -101,11 +103,16 @@ public static void ProcessBundle(string baseFolder, Bundle bundle)
content = FileHelpers.ReadAllText(file);
}

sb.AppendLine(content);
// adding new line only if there are more than 1 files
// otherwise we are preserving file integrity
if (sb.Length > 0)
sb.AppendLine();

sb.Append(content);
}
}

bundle.Output = sb.ToString().Trim();
bundle.Output = sb.ToString();
}

private static bool AdjustRelativePaths(Bundle bundle)
Expand Down

0 comments on commit 092e460

Please sign in to comment.