1
Vote

Console issue: execution order makes minification fail

description

Hi,

I've had a problem when using the console to minify and bundle my js files. The problem is that I reference chirpy-minified files from the bundles and now, in the Main method of the Program.cs file the execution is first bundling and then minifying for each directory.

In my case, bundles are also refering to other folder chirpy minifed items so I had to implement a change to the code in order to make it work:

static void Main(string[] args)
{
System.DateTime d = System.DateTime.Now;
System.Console.WriteLine("PLEASE, MAKE SURE ALL THE FILES IN YOUR FOLDER ARE NOT WRITE PROTECTED.\nPRESS ANY KEY TO CONTINUE");
System.Console.Read();
string findPath = string.Empty;
if (args.Length > 0)
{
    findPath = args[0];
}

//GoogleClosureJavaPath = "";

string[] dirs = Directory.GetDirectories(findPath, "*", SearchOption.AllDirectories);

//first we make only file compressions
EngineDirectory(findPath);
foreach (var directory in dirs)
{
    EngineDirectory(directory);
}

//then we make bundles.
//double iteration but bundles can now make a reference to already minified files.

ConfigDirectory(findPath);
foreach (var directory in dirs)
{
    ConfigDirectory(directory);
}
System.Console.WriteLine("Spent time: " + (d - System.DateTime.Now).ToString());
}


As you can see I've splitted the execution in two loops and inverted the order. I think this works in all situations although it takes more execution time.

I just wanted to let you know my scenario in case you want to update the project to cover it.

Best regards,

Roberto.

comments