-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
89 lines (79 loc) · 2.77 KB
/
Copy pathProgram.cs
File metadata and controls
89 lines (79 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using CookPopularInstaller.Toolkit.Helpers;
using CookPopularInstaller.Toolkit;
using System;
using System.IO;
using System.Text;
namespace CookPopularInstaller.Generate.CommandLine
{
internal class Program
{
private static string packageJsonFileName = string.Empty;
static void Usage()
{
Console.WriteLine("example: CookPopularInstaller.Generate.CommandLine build package.json");
}
static void Main(string[] args)
{
if (args.Length == 2)
{
if (args[0] == "build" && Path.GetExtension(args[1]) == ".json")
{
packageJsonFileName = args[1];
Build();
}
else
{
Usage();
}
}
else
{
Usage();
}
}
private static bool Start(PackageInfo package, string operation)
{
Console.WriteLine($"start {operation.ToLower()} ...");
int index = 0;
bool hasError = false;
IList<string> arguments;
if (operation == "Confuse")
arguments = Toolkit.Build.GetConfuseArguments(package.Project.PackageFolder, packageJsonFileName);
else
arguments = Toolkit.Build.GetBuildArguments(package, packageJsonFileName);
do
{
ProcessHelper.StartCmd(arguments.ElementAt(index), out StringBuilder output, out bool isError);
hasError |= isError;
var outputStr = output.ToString().ToLower();
hasError |= (outputStr.Contains("error") || outputStr.Contains("fatal"));
Console.WriteLine(output.ToString());
index++;
} while (index < arguments.Count && !hasError);
if (hasError)
Console.WriteLine($"{operation} Failed!");
else
Console.WriteLine($"{operation} Successfully!");
return hasError;
}
private static void Build()
{
Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory + "..\\";
Toolkit.Build.Configure(packageJsonFileName);
var package = Toolkit.Build.ReadPackageJsonFile(packageJsonFileName);
if (package.Confuse.IsConfuse)
{
var confuseResult = Start(package, "Confuse");
if (!confuseResult)
{
Toolkit.Build.CopyConfusedFilesToPackageFolder(package.Project.PackageFolder);
Start(package, "Build");
}
}
else
{
Start(package, "Build");
}
}
}
}