@@ -86,10 +86,20 @@ private void SetModulesInTempPath()
86
86
// we assume the modules have not been tampered with
87
87
foreach ( var dir in Directory . EnumerateDirectories ( tempDirPath ) )
88
88
{
89
- modulesSavedInTempPath . Add ( Path . GetFileName ( dir ) ) ;
89
+ AddModuleName ( modulesSavedInTempPath , Path . GetFileName ( dir ) ) ;
90
90
}
91
91
}
92
92
93
+ private void AddModuleName ( HashSet < string > hashSet , string moduleName )
94
+ {
95
+ hashSet . Add ( moduleName . ToLower ( ) ) ;
96
+ }
97
+
98
+ private bool IsModuleNamePresent ( HashSet < string > hashSet , string moduleName )
99
+ {
100
+ return hashSet . Contains ( moduleName . ToLower ( ) ) ;
101
+ }
102
+
93
103
private void SetupTempDir ( )
94
104
{
95
105
CreateTempDir ( ) ;
@@ -138,7 +148,7 @@ private void CleanUp()
138
148
// remove the modules from local psmodule path
139
149
foreach ( var dir in Directory . EnumerateDirectories ( localPSModulePath ) )
140
150
{
141
- if ( modulesSavedInModulePath . Contains ( Path . GetFileName ( dir ) ) )
151
+ if ( IsModuleNamePresent ( modulesSavedInModulePath , Path . GetFileName ( dir ) ) )
142
152
{
143
153
Directory . Delete ( dir , true ) ;
144
154
}
@@ -220,6 +230,7 @@ public void SetupDefaultRunspace(Runspace runspace)
220
230
public PSObject FindModule ( string moduleName )
221
231
{
222
232
ThrowIfNull ( moduleName , "moduleName" ) ;
233
+ moduleName = moduleName . ToLower ( ) ;
223
234
if ( modulesFound . ContainsKey ( moduleName ) )
224
235
{
225
236
return modulesFound [ moduleName ] ;
@@ -256,11 +267,11 @@ public bool ModuleExists(string moduleName)
256
267
public void SaveModule ( string moduleName )
257
268
{
258
269
ThrowIfNull ( moduleName , "moduleName" ) ;
259
- if ( modulesSavedInModulePath . Contains ( moduleName ) )
270
+ if ( IsModuleNamePresent ( modulesSavedInModulePath , moduleName ) )
260
271
{
261
272
return ;
262
273
}
263
- if ( modulesSavedInTempPath . Contains ( moduleName ) )
274
+ if ( IsModuleNamePresent ( modulesSavedInTempPath , moduleName ) )
264
275
{
265
276
// copy to local ps module path
266
277
CopyToPSModulePath ( moduleName ) ;
@@ -277,7 +288,7 @@ public void SaveModule(string moduleName)
277
288
moduleRepository ) ) ;
278
289
}
279
290
SaveModule ( module ) ;
280
- modulesSavedInTempPath . Add ( moduleName ) ;
291
+ AddModuleName ( modulesSavedInTempPath , moduleName ) ;
281
292
CopyToPSModulePath ( moduleName ) ;
282
293
}
283
294
@@ -294,7 +305,7 @@ private void CopyToPSModulePath(string moduleName, bool checkModulePresence = fa
294
305
}
295
306
}
296
307
CopyDir ( Path . Combine ( tempDirPath , moduleName ) , localPSModulePath ) ;
297
- modulesSavedInModulePath . Add ( moduleName ) ;
308
+ AddModuleName ( modulesSavedInModulePath , moduleName ) ;
298
309
}
299
310
300
311
public static string GetModuleNameFromErrorExtent ( ParseError error , ScriptBlockAst ast )
0 commit comments