Skip to content

Commit

Permalink
chore: minor #1
Browse files Browse the repository at this point in the history
  • Loading branch information
godrose committed Mar 12, 2021
1 parent 20ad86c commit 2b18df1
Showing 1 changed file with 31 additions and 33 deletions.
64 changes: 31 additions & 33 deletions devops/pack/Pack/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,61 @@ namespace Pack
{
internal static class Program
{
static void Main(string[] args)
private static void Main(string[] args)
{
GoUp(5);
var single = args != null && args.Length > 0 ? args[0] : null;
var single = args != null && args.Length > 0 ? args[0] : null;
if (single != null)
{
PackSingle(Path.Combine(Directory.GetCurrentDirectory(), single));
return;
}

foreach (var dir in Directory.GetDirectories(Directory.GetCurrentDirectory()))
{
if (dir.EndsWith("tools")) continue;
PackSingle(dir);
PackSingle(dir);
}
}

private static void PackSingle(string dir)
{
Console.WriteLine(dir);
var devopsDir = Path.Combine(dir, "devops");
if (Directory.Exists(devopsDir))
Console.WriteLine(dir);
var devopsDir = Path.Combine(dir, "devops");
if (!Directory.Exists(devopsDir)) return;
Directory.SetCurrentDirectory(devopsDir);
var packDir = Path.Combine(devopsDir, "pack");
if (Directory.Exists(packDir))
{
Directory.SetCurrentDirectory(packDir);
var packBat = Path.Combine(packDir, "pack.bat");
if (File.Exists(packBat))
{
Directory.SetCurrentDirectory(devopsDir);
var packDir = Path.Combine(devopsDir, "pack");
if (Directory.Exists(packDir))
{
Directory.SetCurrentDirectory(packDir);
var packBat = Path.Combine(packDir, "pack.bat");
if (File.Exists(packBat))
{
var process = Process.Start(packBat);
process.WaitForExit();
}
else
{
var packAllBat = Path.Combine(packDir, "pack-all.bat");
if (File.Exists(packAllBat))
{
var process = Process.Start(packAllBat);
process.WaitForExit();
}
}
GoUp(3);
}
else
var process = Process.Start(packBat);
process.WaitForExit();
}
else
{
var packAllBat = Path.Combine(packDir, "pack-all.bat");
if (File.Exists(packAllBat))
{
GoUp(2);
var process = Process.Start(packAllBat);
process.WaitForExit();
}
}
GoUp(3);
}
else
{
GoUp(2);
}
}

private static void GoUp(int numberOfLevels)
{
var relativePath = new List<string> { Directory.GetCurrentDirectory() };
var relativePath = new List<string> {Directory.GetCurrentDirectory()};
relativePath.AddRange(Enumerable.Repeat("..", numberOfLevels));
Directory.SetCurrentDirectory(Path.Combine(relativePath.ToArray()));
}
}
}
}

0 comments on commit 2b18df1

Please sign in to comment.