@@ -10,29 +10,21 @@ namespace Semmle.Autobuild.Shared
1010 public class BuildCommandAutoRule : IBuildRule < AutobuildOptionsShared >
1111 {
1212 private readonly WithDotNet < AutobuildOptionsShared > withDotNet ;
13- private IEnumerable < string > candidatePaths ;
14- private string ? scriptPath ;
1513
1614 /// <summary>
1715 /// A list of paths to files in the project directory which we classified as scripts.
1816 /// </summary>
19- public IEnumerable < string > CandidatePaths
20- {
21- get { return this . candidatePaths ; }
22- }
17+ public IEnumerable < string > CandidatePaths { get ; private set ; }
2318
2419 /// <summary>
2520 /// The path of the script we decided to run, if any.
2621 /// </summary>
27- public string ? ScriptPath
28- {
29- get { return this . scriptPath ; }
30- }
22+ public string ? ScriptPath { get ; private set ; }
3123
3224 public BuildCommandAutoRule ( WithDotNet < AutobuildOptionsShared > withDotNet )
3325 {
3426 this . withDotNet = withDotNet ;
35- this . candidatePaths = new List < string > ( ) ;
27+ this . CandidatePaths = new List < string > ( ) ;
3628 }
3729
3830 /// <summary>
@@ -70,18 +62,18 @@ public BuildScript Analyse(IAutobuilder<AutobuildOptionsShared> builder, bool au
7062 var scripts = buildScripts . SelectMany ( s => extensions . Select ( e => s + e ) ) ;
7163 // search through the files in the project directory for paths which end in one of
7264 // the names given by `scripts`, then order them by their distance from the root
73- this . candidatePaths = builder . Paths . Where ( p => scripts . Any ( p . Item1 . ToLower ( ) . EndsWith ) ) . OrderBy ( p => p . Item2 ) . Select ( p => p . Item1 ) ;
65+ this . CandidatePaths = builder . Paths . Where ( p => scripts . Any ( p . Item1 . ToLower ( ) . EndsWith ) ) . OrderBy ( p => p . Item2 ) . Select ( p => p . Item1 ) ;
7466 // pick the first matching path, if there is one
75- this . scriptPath = candidatePaths . FirstOrDefault ( ) ;
67+ this . ScriptPath = this . CandidatePaths . FirstOrDefault ( ) ;
7668
77- if ( scriptPath is null )
69+ if ( this . ScriptPath is null )
7870 return BuildScript . Failure ;
7971
8072 var chmod = new CommandBuilder ( builder . Actions ) ;
81- chmod . RunCommand ( "/bin/chmod" , $ "u+x { scriptPath } ") ;
73+ chmod . RunCommand ( "/bin/chmod" , $ "u+x { this . ScriptPath } ") ;
8274 var chmodScript = builder . Actions . IsWindows ( ) ? BuildScript . Success : BuildScript . Try ( chmod . Script ) ;
8375
84- var dir = builder . Actions . GetDirectoryName ( scriptPath ) ;
76+ var dir = builder . Actions . GetDirectoryName ( this . ScriptPath ) ;
8577
8678 // A specific .NET Core version may be required
8779 return chmodScript & withDotNet ( builder , environment =>
@@ -93,7 +85,7 @@ public BuildScript Analyse(IAutobuilder<AutobuildOptionsShared> builder, bool au
9385 if ( vsTools is not null )
9486 command . CallBatFile ( vsTools . Path ) ;
9587
96- command . RunCommand ( scriptPath ) ;
88+ command . RunCommand ( this . ScriptPath ) ;
9789 return command . Script ;
9890 } ) ;
9991 }
0 commit comments