Skip to content

Commit

Permalink
Choco installer also will deploy PowerShell gsudoModule to '%ProgramF…
Browse files Browse the repository at this point in the history
…iles%\PowerShell\Modules\gsudoModule\'
  • Loading branch information
gerardog committed Jul 17, 2023
1 parent 58cfcd6 commit fc2345f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions build/Chocolatey/gsudo/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ Install-ChocolateyPath -PathToInstall $SymLinkDir -PathType 'Machine'

cmd /c mklink "$TargetDir\sudo.exe" "$TargetDir\gsudo.exe" 2>$null

# Copy gsudoModule to "$env:ProgramFiles\PowerShell\Modules\gsudoModule"
$PSModulesTargetDir = "$env:ProgramFiles\PowerShell\Modules\gsudoModule"
md $PSModulesTargetDir -ErrorAction SilentlyContinue
copy "$bin\*.ps*" $TargetDir -Exclude *.ignore -Force

$OldCurrentDir = Get-Item $SymLinkDir -ErrorAction ignore
if ($OldCurrentDir)
{
Expand All @@ -43,13 +48,13 @@ cmd /c mklink /d "$SymLinkDir" "$TargetDir\"
Write-Output "gsudo successfully installed. Please restart your consoles to use gsudo.`n"

if (Get-Module gsudoModule) {
"Please restart PowerShell to update PowerShell gsudo Module."
"Please restart all your PowerShell consoles to update PowerShell gsudo Module."
} else {
& {
"PowerShell users: To use enhanced gsudo and Invoke-Gsudo cmdlet, add the following line to your `$PROFILE"
" Import-Module '$SymLinkDir\gsudoModule.psd1'"
"PowerShell users: Add auto-complete to gsudo by adding the following line to your `$PROFILE"
" Import-Module 'gsudoModule'"
"Or run: "
" Write-Output `"``nImport-Module '$SymLinkDir\gsudoModule.psd1'`" | Add-Content `$PROFILE"
" Write-Output `"``nImport-Module 'gsudoModule'`" | Add-Content `$PROFILE"

}
}
4 changes: 2 additions & 2 deletions installgsudo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ else
Write-Output "Please restart your consoles to use gsudo!`n"

"PowerShell users: To use enhanced gsudo and Invoke-Gsudo cmdlet, add the following line to your `$PROFILE"
" Import-Module '${Env:ProgramFiles}\gsudo\Current\gsudoModule.psd1'"
" Import-Module 'gsudoModule'"
"Or run: "
" New-Item -Type Directory (`$PROFILE | Split-Path) -ErrorAction Ignore"
" Write-Output `"``nImport-Module '${Env:ProgramFiles}\gsudo\Current\gsudoModule.psd1'`" | Add-Content `$PROFILE"
" Write-Output `"``nImport-Module 'gsudoModule'`" | Add-Content `$PROFILE"

Remove-Item $fileName
}
Expand Down

0 comments on commit fc2345f

Please sign in to comment.