11using System ;
22using System . Diagnostics ;
33using System . IO ;
4+ using System . Linq ;
5+ using System . Text . RegularExpressions ;
46
57namespace DocGenerator
68{
@@ -14,6 +16,7 @@ string P(string path)
1416 }
1517
1618 var currentDirectory = new DirectoryInfo ( Directory . GetCurrentDirectory ( ) ) ;
19+ var globalJson = P ( @"..\..\..\global.json" ) ;
1720 if ( currentDirectory . Name == "DocGenerator" && currentDirectory . Parent . Name == "CodeGeneration" )
1821 {
1922 Console . WriteLine ( "IDE: " + currentDirectory ) ;
@@ -23,12 +26,21 @@ string P(string path)
2326 }
2427 else
2528 {
29+ globalJson = P ( @"..\..\..\..\global.json" ) ;
2630 Console . WriteLine ( "CMD: " + currentDirectory ) ;
2731 InputDirPath = P ( @"..\..\..\..\src" ) ;
2832 OutputDirPath = P ( @"..\..\..\..\docs" ) ;
2933 BuildOutputPath = P ( @"..\..\..\..\build\output" ) ;
3034 }
3135
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+
3244 var process = new Process
3345 {
3446 StartInfo = new ProcessStartInfo
@@ -68,7 +80,7 @@ string P(string path)
6880 /// <summary>
6981 /// The Elasticsearch documentation version to link to
7082 /// </summary>
71- public static string DocVersion => "6.5" ;
83+ public static string DocVersion { get ; set ; }
7284
7385 public static string InputDirPath { get ; }
7486
0 commit comments