@@ -8,8 +8,14 @@ namespace GitHub.Unity
8
8
public class DefaultEnvironment : IEnvironment
9
9
{
10
10
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 ;
11
18
12
- public NPath LogPath { get ; }
13
19
public DefaultEnvironment ( )
14
20
{
15
21
NPath localAppData ;
@@ -36,12 +42,21 @@ public DefaultEnvironment()
36
42
LogPath = UserCachePath . Combine ( logFile ) ;
37
43
}
38
44
39
- public DefaultEnvironment ( ICacheContainer cacheContainer )
40
- : this ( )
45
+ public DefaultEnvironment ( ICacheContainer cacheContainer ) : this ( )
41
46
{
42
47
this . CacheContainer = cacheContainer ;
43
48
}
44
49
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
+
45
60
public void Initialize ( string unityVersion , NPath extensionInstallPath , NPath unityApplicationPath , NPath unityApplicationContentsPath , NPath assetsPath )
46
61
{
47
62
ExtensionInstallPath = extensionInstallPath ;
@@ -107,6 +122,7 @@ public string GetEnvironmentVariable(string variable)
107
122
return Environment . GetEnvironmentVariable ( variable ) ;
108
123
}
109
124
125
+ public NPath LogPath { get ; }
110
126
public IFileSystem FileSystem { get { return NPath . FileSystem ; } set { NPath . FileSystem = value ; } }
111
127
public string UnityVersion { get ; set ; }
112
128
public NPath UnityApplication { get ; set ; }
@@ -116,42 +132,43 @@ public string GetEnvironmentVariable(string variable)
116
132
public NPath ExtensionInstallPath { get ; set ; }
117
133
public NPath UserCachePath { get ; set ; }
118
134
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
+ }
124
150
public NPath GitExecutablePath
125
151
{
126
152
get { return gitExecutablePath ; }
127
153
set
128
154
{
129
155
gitExecutablePath = value ;
130
- if ( String . IsNullOrEmpty ( gitExecutablePath ) )
156
+ if ( ! gitExecutablePath . IsInitialized )
131
157
GitInstallPath = NPath . Default ;
132
158
else
133
159
GitInstallPath = GitExecutablePath . Resolve ( ) . Parent . Parent ;
134
160
}
135
161
}
136
-
137
- private NPath nodeJsExecutablePath ;
138
-
139
162
public NPath NodeJsExecutablePath
140
163
{
141
164
get
142
165
{
143
166
if ( ! nodeJsExecutablePath . IsInitialized )
144
- {
145
- nodeJsExecutablePath =
146
- UnityApplicationContents . Combine ( "Tools" , "nodejs" , "node" + ExecutableExtension ) ;
147
- }
148
-
167
+ nodeJsExecutablePath = UnityApplicationContents . Combine ( "Tools" , "nodejs" , "node" + ExecutableExtension ) ;
149
168
return nodeJsExecutablePath ;
150
169
}
151
170
}
152
-
153
171
public NPath GitInstallPath { get ; private set ; }
154
-
155
172
public NPath RepositoryPath { get ; private set ; }
156
173
public ICacheContainer CacheContainer { get ; private set ; }
157
174
public IRepository Repository { get ; set ; }
@@ -161,17 +178,6 @@ public NPath NodeJsExecutablePath
161
178
public bool IsLinux { get { return OnLinux ; } }
162
179
public bool IsMac { get { return OnMac ; } }
163
180
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 ;
175
181
public static bool OnWindows
176
182
{
177
183
get
@@ -183,7 +189,6 @@ public static bool OnWindows
183
189
set { onWindows = value ; }
184
190
}
185
191
186
- private static bool ? onLinux ;
187
192
public static bool OnLinux
188
193
{
189
194
get
@@ -195,7 +200,6 @@ public static bool OnLinux
195
200
set { onLinux = value ; }
196
201
}
197
202
198
- private static bool ? onMac ;
199
203
public static bool OnMac
200
204
{
201
205
get
@@ -208,6 +212,7 @@ public static bool OnMac
208
212
}
209
213
set { onMac = value ; }
210
214
}
215
+
211
216
public string ExecutableExtension { get { return IsWindows ? ".exe" : string . Empty ; } }
212
217
protected static ILogging Logger { get ; } = LogHelper . GetLogger < DefaultEnvironment > ( ) ;
213
218
}
0 commit comments