File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -263,8 +263,7 @@ public void SaveModule(string moduleName)
263263 if ( modulesSavedInTempPath . Contains ( moduleName ) )
264264 {
265265 // copy to local ps module path
266- CopyDir ( Path . Combine ( tempDirPath , moduleName ) , localPSModulePath ) ;
267- modulesSavedInModulePath . Add ( moduleName ) ;
266+ CopyToPSModulePath ( moduleName ) ;
268267 return ;
269268 }
270269
@@ -278,9 +277,22 @@ public void SaveModule(string moduleName)
278277 moduleRepository ) ) ;
279278 }
280279 SaveModule ( module ) ;
281- modulesSavedInTempPath . Add ( moduleName ) ;
280+ modulesSavedInTempPath . Add ( moduleName ) ;
281+ CopyToPSModulePath ( moduleName ) ;
282+ }
282283
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+ }
284296 CopyDir ( Path . Combine ( tempDirPath , moduleName ) , localPSModulePath ) ;
285297 modulesSavedInModulePath . Add ( moduleName ) ;
286298 }
You can’t perform that action at this time.
0 commit comments