@@ -8,8 +8,14 @@ namespace GitHub.Unity
88 public class DefaultEnvironment : IEnvironment
99 {
1010 private const string logFile = "github-unity.log" ;
11+ private static bool ? onWindows ;
12+ private static bool ? onLinux ;
13+ private static bool ? onMac ;
14+
15+ private NPath gitExecutablePath ;
16+ private NPath nodeJsExecutablePath ;
17+ private NPath octorunScriptPath ;
1118
12- public NPath LogPath { get ; }
1319 public DefaultEnvironment ( )
1420 {
1521 NPath localAppData ;
@@ -36,12 +42,21 @@ public DefaultEnvironment()
3642 LogPath = UserCachePath . Combine ( logFile ) ;
3743 }
3844
39- public DefaultEnvironment ( ICacheContainer cacheContainer )
40- : this ( )
45+ public DefaultEnvironment ( ICacheContainer cacheContainer ) : this ( )
4146 {
4247 this . CacheContainer = cacheContainer ;
4348 }
4449
50+ /// <summary>
51+ /// This is for tests to reset the static OS flags
52+ /// </summary>
53+ public static void Reset ( )
54+ {
55+ onWindows = null ;
56+ onLinux = null ;
57+ onMac = null ;
58+ }
59+
4560 public void Initialize ( string unityVersion , NPath extensionInstallPath , NPath unityApplicationPath , NPath unityApplicationContentsPath , NPath assetsPath )
4661 {
4762 ExtensionInstallPath = extensionInstallPath ;
@@ -107,6 +122,7 @@ public string GetEnvironmentVariable(string variable)
107122 return Environment . GetEnvironmentVariable ( variable ) ;
108123 }
109124
125+ public NPath LogPath { get ; }
110126 public IFileSystem FileSystem { get { return NPath . FileSystem ; } set { NPath . FileSystem = value ; } }
111127 public string UnityVersion { get ; set ; }
112128 public NPath UnityApplication { get ; set ; }
@@ -116,42 +132,43 @@ public string GetEnvironmentVariable(string variable)
116132 public NPath ExtensionInstallPath { get ; set ; }
117133 public NPath UserCachePath { get ; set ; }
118134 public NPath SystemCachePath { get ; set ; }
119- public NPath Path { get { return Environment . GetEnvironmentVariable ( "PATH" ) . ToNPath ( ) ; } }
120- public string NewLine { get { return Environment . NewLine ; } }
121- public NPath OctorunScriptPath { get ; set ; }
122-
123- private NPath gitExecutablePath ;
135+ public NPath Path => Environment . GetEnvironmentVariable ( "PATH" ) . ToNPath ( ) ;
136+ public string NewLine => Environment . NewLine ;
137+ public NPath OctorunScriptPath
138+ {
139+ get
140+ {
141+ if ( ! octorunScriptPath . IsInitialized )
142+ octorunScriptPath = UserCachePath . Combine ( "octorun" , "src" , "bin" , "app.js" ) ;
143+ return octorunScriptPath ;
144+ }
145+ set
146+ {
147+ octorunScriptPath = value ;
148+ }
149+ }
124150 public NPath GitExecutablePath
125151 {
126152 get { return gitExecutablePath ; }
127153 set
128154 {
129155 gitExecutablePath = value ;
130- if ( String . IsNullOrEmpty ( gitExecutablePath ) )
156+ if ( ! gitExecutablePath . IsInitialized )
131157 GitInstallPath = NPath . Default ;
132158 else
133159 GitInstallPath = GitExecutablePath . Resolve ( ) . Parent . Parent ;
134160 }
135161 }
136-
137- private NPath nodeJsExecutablePath ;
138-
139162 public NPath NodeJsExecutablePath
140163 {
141164 get
142165 {
143166 if ( ! nodeJsExecutablePath . IsInitialized )
144- {
145- nodeJsExecutablePath =
146- UnityApplicationContents . Combine ( "Tools" , "nodejs" , "node" + ExecutableExtension ) ;
147- }
148-
167+ nodeJsExecutablePath = UnityApplicationContents . Combine ( "Tools" , "nodejs" , "node" + ExecutableExtension ) ;
149168 return nodeJsExecutablePath ;
150169 }
151170 }
152-
153171 public NPath GitInstallPath { get ; private set ; }
154-
155172 public NPath RepositoryPath { get ; private set ; }
156173 public ICacheContainer CacheContainer { get ; private set ; }
157174 public IRepository Repository { get ; set ; }
@@ -161,17 +178,6 @@ public NPath NodeJsExecutablePath
161178 public bool IsLinux { get { return OnLinux ; } }
162179 public bool IsMac { get { return OnMac ; } }
163180
164- /// <summary>
165- /// This is for tests to reset the static OS flags
166- /// </summary>
167- public static void Reset ( )
168- {
169- onWindows = null ;
170- onLinux = null ;
171- onMac = null ;
172- }
173-
174- private static bool ? onWindows ;
175181 public static bool OnWindows
176182 {
177183 get
@@ -183,7 +189,6 @@ public static bool OnWindows
183189 set { onWindows = value ; }
184190 }
185191
186- private static bool ? onLinux ;
187192 public static bool OnLinux
188193 {
189194 get
@@ -195,7 +200,6 @@ public static bool OnLinux
195200 set { onLinux = value ; }
196201 }
197202
198- private static bool ? onMac ;
199203 public static bool OnMac
200204 {
201205 get
@@ -208,6 +212,7 @@ public static bool OnMac
208212 }
209213 set { onMac = value ; }
210214 }
215+
211216 public string ExecutableExtension { get { return IsWindows ? ".exe" : string . Empty ; } }
212217 protected static ILogging Logger { get ; } = LogHelper . GetLogger < DefaultEnvironment > ( ) ;
213218 }
0 commit comments