@@ -50,9 +50,8 @@ public string TempPath
50
50
private set
51
51
{
52
52
tempPath
53
- = ( string . IsNullOrEmpty ( value )
54
- || string . IsNullOrWhiteSpace ( value ) )
55
- ? Environment . GetEnvironmentVariable ( "TEMP" )
53
+ = string . IsNullOrWhiteSpace ( value )
54
+ ? Path . GetTempPath ( )
56
55
: value ;
57
56
}
58
57
@@ -69,10 +68,9 @@ public string LocalAppDataPath
69
68
}
70
69
private set
71
70
{
72
- localAppdataPath
73
- = ( string . IsNullOrEmpty ( value )
74
- || string . IsNullOrWhiteSpace ( value ) )
75
- ? Environment . GetEnvironmentVariable ( "LOCALAPPDATA" )
71
+ localAppdataPath
72
+ = string . IsNullOrWhiteSpace ( value )
73
+ ? Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData )
76
74
: value ;
77
75
}
78
76
}
@@ -90,8 +88,7 @@ public string ModuleRepository
90
88
set
91
89
{
92
90
moduleRepository
93
- = ( string . IsNullOrEmpty ( value )
94
- || string . IsNullOrWhiteSpace ( value ) )
91
+ = string . IsNullOrWhiteSpace ( value )
95
92
? "PSGallery"
96
93
: value ;
97
94
}
@@ -106,14 +103,6 @@ public string PSSAAppDataPath
106
103
{
107
104
return pssaAppDataPath ;
108
105
}
109
- private set
110
- {
111
- var leaf
112
- = ( string . IsNullOrEmpty ( value ) || string . IsNullOrWhiteSpace ( value ) )
113
- ? "PSScriptAnalyzer"
114
- : value ;
115
- pssaAppDataPath = Path . Combine ( LocalAppDataPath , leaf ) ;
116
- }
117
106
}
118
107
119
108
/// <summary>
@@ -156,8 +145,7 @@ private void SetupPSSAAppData()
156
145
tempModulePath = GetTempModulePath ( symLinkPath ) ;
157
146
158
147
// check if the temp dir exists
159
- if ( tempModulePath != null
160
- && Directory . Exists ( tempModulePath ) )
148
+ if ( Directory . Exists ( tempModulePath ) )
161
149
{
162
150
return ;
163
151
}
@@ -204,12 +192,12 @@ private string GetPSSATempDirPath()
204
192
// Return the first line of the file
205
193
private string GetTempModulePath ( string symLinkPath )
206
194
{
207
- var symLinkLines = File . ReadAllLines ( symLinkPath ) ;
208
- if ( symLinkLines . Length != 1 )
195
+ string line ;
196
+ using ( var fileStream = new StreamReader ( symLinkPath ) )
209
197
{
210
- return null ;
198
+ line = fileStream . ReadLine ( ) ;
211
199
}
212
- return symLinkLines [ 0 ] ;
200
+ return line ;
213
201
}
214
202
215
203
private void SaveModule ( PSObject module )
@@ -278,9 +266,13 @@ public ModuleDependencyHandler(
278
266
// and then passed into modulehandler
279
267
TempPath = tempPath ;
280
268
LocalAppDataPath = localAppDataPath ;
281
- PSSAAppDataPath = pssaAppDataPath ;
282
269
ModuleRepository = moduleRepository ;
283
-
270
+ pssaAppDataPath = Path . Combine (
271
+ LocalAppDataPath ,
272
+ string . IsNullOrWhiteSpace ( pssaAppDataPath )
273
+ ? "PSScriptAnalyzer"
274
+ : pssaAppDataPath ) ;
275
+
284
276
modulesFound = new Dictionary < string , PSObject > ( ) ;
285
277
286
278
// TODO Add PSSA Version in the path
0 commit comments