Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

During install create the profile dir if it does not already exist #449

Merged
merged 1 commit into from
Mar 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ function Add-PoshGitToProfile {
$profileContent = "`nImport-Module '$ModuleBasePath\posh-git.psd1'"
}

# Make sure the PowerShell profile directory exists
$profileDir = Split-Path $profilePath -Parent
if (!(Test-Path -LiteralPath $profileDir)) {
if ($PSCmdlet.ShouldProcess($profileDir, "Create current user PowerShell profile directory")) {
New-Item $profileDir -ItemType Directory -Verbose:$VerbosePreference > $null
}
}

if ($PSCmdlet.ShouldProcess($profilePath, "Add 'Import-Module posh-git' to profile")) {
Add-Content -LiteralPath $profilePath -Value $profileContent -Encoding UTF8
}
Expand Down