forked from elastic/elasticsearch-net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
90 lines (78 loc) · 2.05 KB
/
Program.cs
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
using System;
using System.Diagnostics;
using System.IO;
namespace DocGenerator
{
public static class Program
{
static Program()
{
string P(string path)
{
return path.Replace(@"\", Path.DirectorySeparatorChar.ToString());
}
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
if (currentDirectory.Name == "DocGenerator" && currentDirectory.Parent.Name == "CodeGeneration")
{
Console.WriteLine("IDE: " + currentDirectory);
InputDirPath = P(@"..\..\");
OutputDirPath = P(@"..\..\..\docs");
BuildOutputPath = P(@"..\..\..\src");
}
else
{
Console.WriteLine("CMD: " + currentDirectory);
InputDirPath = P(@"..\..\..\..\src");
OutputDirPath = P(@"..\..\..\..\docs");
BuildOutputPath = P(@"..\..\..\..\build\output");
}
var process = new Process
{
StartInfo = new ProcessStartInfo
{
UseShellExecute = false,
RedirectStandardOutput = true,
FileName = "git.exe",
CreateNoWindow = true,
WorkingDirectory = Environment.CurrentDirectory,
Arguments = "rev-parse --abbrev-ref HEAD"
}
};
try
{
process.Start();
BranchName = process.StandardOutput.ReadToEnd().Trim();
Console.WriteLine($"Using branch name {BranchName} in documentation");
process.WaitForExit();
}
catch (Exception)
{
BranchName = "master";
Console.WriteLine($"Could not get the git branch name. Assuming {BranchName}");
}
finally
{
process.Dispose();
}
}
public static string BuildOutputPath { get; }
public static string InputDirPath { get; }
public static string OutputDirPath { get; }
public static string BranchName { get; }
public static string DocVersion => "6.1";
static int Main(string[] args)
{
try
{
LitUp.GoAsync(args).Wait();
return 0;
}
catch (AggregateException ae)
{
var ex = ae.InnerException ?? ae;
Console.WriteLine(ex.Message);
return 1;
}
}
}
}