File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -263,8 +263,7 @@ public void SaveModule(string moduleName)
263
263
if ( modulesSavedInTempPath . Contains ( moduleName ) )
264
264
{
265
265
// copy to local ps module path
266
- CopyDir ( Path . Combine ( tempDirPath , moduleName ) , localPSModulePath ) ;
267
- modulesSavedInModulePath . Add ( moduleName ) ;
266
+ CopyToPSModulePath ( moduleName ) ;
268
267
return ;
269
268
}
270
269
@@ -278,9 +277,22 @@ public void SaveModule(string moduleName)
278
277
moduleRepository ) ) ;
279
278
}
280
279
SaveModule ( module ) ;
281
- modulesSavedInTempPath . Add ( moduleName ) ;
280
+ modulesSavedInTempPath . Add ( moduleName ) ;
281
+ CopyToPSModulePath ( moduleName ) ;
282
+ }
282
283
283
- // copy to local ps module path
284
+ private void CopyToPSModulePath ( string moduleName , bool checkModulePresence = false )
285
+ {
286
+ if ( checkModulePresence )
287
+ {
288
+ foreach ( var dir in Directory . EnumerateDirectories ( localPSModulePath ) )
289
+ {
290
+ if ( Path . GetFileName ( dir ) . Equals ( moduleName , StringComparison . OrdinalIgnoreCase ) )
291
+ {
292
+ return ;
293
+ }
294
+ }
295
+ }
284
296
CopyDir ( Path . Combine ( tempDirPath , moduleName ) , localPSModulePath ) ;
285
297
modulesSavedInModulePath . Add ( moduleName ) ;
286
298
}
You can’t perform that action at this time.
0 commit comments