@@ -2,56 +2,56 @@ $modulesdir = "$scoopdir\modules"
22
33function install_psmodule ($manifest , $dir , $global ) {
44 $psmodule = $manifest.psmodule
5- if (! $psmodule ) { return }
5+ if (! $psmodule ) { return }
66
7- if ($global ) {
8- abort " Installing PowerShell modules globally is not implemented!"
7+ if ($global ) {
8+ abort ' Installing PowerShell modules globally is not implemented!'
99 }
1010
1111 $modulesdir = ensure $modulesdir
1212 ensure_in_psmodulepath $modulesdir $global
1313
1414 $module_name = $psmodule.name
15- if (! $module_name ) {
15+ if (! $module_name ) {
1616 abort " Invalid manifest: The 'name' property is missing from 'psmodule'."
1717 }
1818
1919 $linkfrom = " $modulesdir \$module_name "
20- write-host " Installing PowerShell module '$module_name '"
20+ Write-Host " Installing PowerShell module '$module_name '"
2121
22- write-host " Linking $ ( friendly_path $linkfrom ) => $ ( friendly_path $dir ) "
22+ Write-Host " Linking $ ( friendly_path $linkfrom ) => $ ( friendly_path $dir ) "
2323
24- if ( test-path $linkfrom ) {
24+ if ( Test-Path $linkfrom ) {
2525 warn " $ ( friendly_path $linkfrom ) already exists. It will be replaced."
26- & " $ env: COMSPEC " / c " rmdir `" $linkfrom `" "
26+ Remove-Item - Path $linkfrom - Force - ErrorAction SilentlyContinue
2727 }
2828
2929 New-Item - Path $linkfrom - ItemType Junction - Value $dir | Out-Null
3030}
3131
3232function uninstall_psmodule ($manifest , $dir , $global ) {
3333 $psmodule = $manifest.psmodule
34- if (! $psmodule ) { return }
34+ if (! $psmodule ) { return }
3535
3636 $module_name = $psmodule.name
37- write-host " Uninstalling PowerShell module '$module_name '."
37+ Write-Host " Uninstalling PowerShell module '$module_name '."
3838
3939 $linkfrom = " $modulesdir \$module_name "
40- if ( test-path $linkfrom ) {
41- write-host " Removing $ ( friendly_path $linkfrom ) "
42- $linkfrom = resolve-path $linkfrom
43- & " $ env: COMSPEC " / c " rmdir `" $linkfrom `" "
40+ if ( Test-Path $linkfrom ) {
41+ Write-Host " Removing $ ( friendly_path $linkfrom ) "
42+ $linkfrom = Resolve-Path $linkfrom
43+ Remove-Item - Path $linkfrom - Force - ErrorAction SilentlyContinue
4444 }
4545}
4646
4747function ensure_in_psmodulepath ($dir , $global ) {
4848 $path = env ' psmodulepath' $global
49- if (! $global -and $null -eq $path ) {
49+ if (! $global -and $null -eq $path ) {
5050 $path = " $env: USERPROFILE \Documents\WindowsPowerShell\Modules"
5151 }
5252 $dir = fullpath $dir
53- if ($path -notmatch [regex ]::escape ($dir )) {
54- write-output " Adding $ ( friendly_path $dir ) to $ ( if ($global ){' global' }else {' your' }) PowerShell module path."
53+ if ($path -notmatch [Regex ]::Escape ($dir )) {
54+ Write-Output " Adding $ ( friendly_path $dir ) to $ ( if ($global ){' global' }else {' your' }) PowerShell module path."
5555
5656 env ' psmodulepath' $global " $dir ;$path " # for future sessions...
5757 $env: psmodulepath = " $dir ;$env: psmodulepath " # for this session
0 commit comments