1
1
using System ;
2
2
using System . Diagnostics ;
3
3
using System . IO ;
4
+ using System . Linq ;
5
+ using System . Text . RegularExpressions ;
4
6
5
7
namespace DocGenerator
6
8
{
@@ -14,6 +16,7 @@ string P(string path)
14
16
}
15
17
16
18
var currentDirectory = new DirectoryInfo ( Directory . GetCurrentDirectory ( ) ) ;
19
+ var globalJson = P ( @"..\..\..\global.json" ) ;
17
20
if ( currentDirectory . Name == "DocGenerator" && currentDirectory . Parent . Name == "CodeGeneration" )
18
21
{
19
22
Console . WriteLine ( "IDE: " + currentDirectory ) ;
@@ -23,12 +26,21 @@ string P(string path)
23
26
}
24
27
else
25
28
{
29
+ globalJson = P ( @"..\..\..\..\global.json" ) ;
26
30
Console . WriteLine ( "CMD: " + currentDirectory ) ;
27
31
InputDirPath = P ( @"..\..\..\..\src" ) ;
28
32
OutputDirPath = P ( @"..\..\..\..\docs" ) ;
29
33
BuildOutputPath = P ( @"..\..\..\..\build\output" ) ;
30
34
}
31
35
36
+ var globalJsonVersion = string . Join ( "." , Regex . Matches ( File . ReadAllText ( globalJson ) , "\" version\" : \" (.*)\" " )
37
+ . Last ( ) . Groups
38
+ . Last ( ) . Value
39
+ . Split ( "." )
40
+ . Take ( 2 ) ) ;
41
+ Console . WriteLine ( "Using global.json version: " + globalJsonVersion ) ;
42
+ DocVersion = globalJsonVersion ;
43
+
32
44
var process = new Process
33
45
{
34
46
StartInfo = new ProcessStartInfo
@@ -68,7 +80,7 @@ string P(string path)
68
80
/// <summary>
69
81
/// The Elasticsearch documentation version to link to
70
82
/// </summary>
71
- public static string DocVersion => "6.4" ;
83
+ public static string DocVersion { get ; set ; }
72
84
73
85
public static string InputDirPath { get ; }
74
86
0 commit comments