-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
131 changed files
with
2,163 additions
and
1,692 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
" Note: You must enable per-project .vimrc in your ~/.vimrc | ||
" set secure | ||
" set exrc | ||
|
||
" PowerShell settings | ||
let g:ale_powershell_psscriptanalyzer_exclusions = "PSAvoidUsingWriteHost,PSUseDeclaredVarsMoreThanAssignments" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,9 @@ curl -fsS https://webi.sh/[email protected] | sh | |
|
||
# Install 'shellcheck v0.9.x' | ||
curl -fsS https://webi.sh/[email protected] | sh | ||
|
||
# Install 'pwsh (PowerShell Core) v7.x' | ||
curl -fsS https://webi.sh/pwsh@7 | sh | ||
# shellcheck disable=SC1090 | ||
. ~/.config/envman/PATH.env | ||
pwsh -Command "Install-Module -Name PSScriptAnalyzer -Scope CurrentUser -AllowClobber" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
set -e | ||
set -u | ||
|
||
echo "Formatting */*.ps1 ... " | ||
for my_ps1 in */*.ps1; do | ||
my_dir="$( | ||
dirname "${my_ps1}" | ||
)" | ||
if test -L "${my_ps1}" || | ||
test -L "${my_dir}" || | ||
! test -f "${my_ps1}" || | ||
! test -d "${my_dir}"; then | ||
printf ' SKIP %s (non-regular file or parent directory)\n' "${my_ps1}" | ||
continue | ||
fi | ||
|
||
printf " %s" "${my_ps1}" | ||
|
||
# -Settings ./Settings/CodeFormatting.psd1 | ||
my_new_file="$( | ||
pwsh -Command "Invoke-Formatter -ScriptDefinition (Get-Content -Path '${my_ps1}' -Raw)" | ||
)" | ||
printf '%s\n' "${my_new_file}" > "${my_ps1}" | ||
|
||
printf '\n' | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env pwsh | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
Write-Host "Formatting */*.ps1 ... " | ||
|
||
$my_cwd = Get-Location | ||
$my_dirs = Get-ChildItem -Directory | ||
$my_status = 0 | ||
|
||
foreach ($my_dir in $my_dirs) { | ||
|
||
$my_files = Get-ChildItem -Path $my_dir.FullName -File -Filter *.ps1 | ||
foreach ($my_file in $my_files) { | ||
$my_ps1 = [System.IO.Path]::GetRelativePath($my_cwd, $my_file.FullName) | ||
$my_dir = [System.IO.Path]::GetDirectoryName($my_file.FullName) | ||
|
||
if (-Not (Test-Path -PathType Leaf -Path $my_ps1) -or | ||
-Not (Test-Path -PathType Container -Path $my_dir)) { | ||
Write-Host (" SKIP {0} (non-regular file or parent directory)" -f $my_ps1) | ||
continue | ||
} | ||
|
||
Write-Host (" {0}" -f $my_ps1) | ||
|
||
$text = Get-Content -Path $my_ps1 -Raw | ||
$my_new_file = Invoke-Formatter -ScriptDefinition $text | ||
$my_new_file = $my_new_file.Trim() | ||
|
||
# note: trailing newline is added back on write | ||
$my_new_file | Set-Content -Path $my_ps1 | ||
|
||
$my_new_file = $my_new_file + "`n" | ||
IF ($text -ne $my_new_file) { | ||
$my_status = 1 | ||
} | ||
} | ||
} | ||
|
||
exit $my_status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/sh | ||
set -e | ||
set -u | ||
|
||
echo "Formatting */*.ps1 ..." | ||
|
||
for my_ps1 in */*.ps1; do | ||
my_dir="$( | ||
dirname "${my_ps1}" | ||
)" | ||
if test -L "${my_ps1}" || | ||
test -L "${my_dir}" || | ||
! test -f "${my_ps1}" || | ||
! test -d "${my_dir}"; then | ||
printf ' SKIP %s (non-regular file or parent directory)\n' "${my_ps1}" | ||
continue | ||
fi | ||
|
||
printf " %s" "${my_ps1}" | ||
|
||
# -Settings ./PSScriptAnalyzerSettings.psd1 | ||
pwsh -Command "Invoke-ScriptAnalyzer -Fix -ExcludeRule PSAvoidUsingWriteHost,PSUseDeclaredVarsMoreThanAssignment -Path '$my_ps1'" | ||
|
||
# | ||
# fmt MUST happen after lint due to Byte-Order Marker (BOM) issues | ||
# See https://github.com/PowerShell/PSScriptAnalyzer/issues/1743 | ||
# | ||
|
||
# -Settings ./Settings/CodeFormatting.psd1 | ||
my_new_file="$( | ||
pwsh -Command "Invoke-Formatter -ScriptDefinition (Get-Content -Path '${my_ps1}' -Raw)" | ||
)" | ||
printf '%s\n' "${my_new_file}" > "${my_ps1}" | ||
|
||
printf '\n' | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env pwsh | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
Write-Host "Linting */*.ps1 ... " | ||
|
||
$my_cwd = Get-Location | ||
$my_dirs = Get-ChildItem -Directory | ||
$my_status = 0 | ||
|
||
foreach ($my_dir in $my_dirs) { | ||
|
||
$my_files = Get-ChildItem -Path $my_dir.FullName -File -Filter *.ps1 | ||
foreach ($my_file in $my_files) { | ||
$my_ps1 = [System.IO.Path]::GetRelativePath($my_cwd, $my_file.FullName) | ||
$my_dir = [System.IO.Path]::GetDirectoryName($my_file.FullName) | ||
|
||
if (-Not (Test-Path -PathType Leaf -Path $my_ps1) -or | ||
-Not (Test-Path -PathType Container -Path $my_dir)) { | ||
Write-Host (" SKIP {0} (non-regular file or parent directory)" -f $my_ps1) | ||
continue | ||
} | ||
|
||
Write-Host (" {0}" -f $my_ps1) | ||
|
||
$my_old_file = (Get-Content -Path $my_ps1 -Raw) | ||
Invoke-ScriptAnalyzer -Fix -ExcludeRule PSAvoidUsingWriteHost, PSUseDeclaredVarsMoreThanAssignment -Path $my_ps1 | ||
|
||
# | ||
# fmt MUST happen after lint due to Byte-Order Marker (BOM) issues | ||
# See https://github.com/PowerShell/PSScriptAnalyzer/issues/1743 | ||
# | ||
|
||
$my_fixed_file = (Get-Content -Path $my_ps1 -Raw) | ||
$my_new_file = Invoke-Formatter -ScriptDefinition $my_fixed_file | ||
$my_new_file = $my_new_file.Trim() | ||
|
||
# note: trailing newline is added back on write | ||
$my_new_file | Set-Content -Path $my_ps1 | ||
|
||
$my_new_file = $my_new_file + "`n" | ||
IF ($my_old_file -ne $my_new_file) { | ||
$my_status = 1 | ||
} | ||
} | ||
} | ||
|
||
exit $my_status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/env pwsh | ||
|
||
IF (!(Test-Path -Path "$Env:USERPROFILE\.vim\pack\plugins\start")) { | ||
New-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start" -ItemType Directory -Force | out-null | ||
New-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start" -ItemType Directory -Force | Out-Null | ||
} | ||
Remove-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start\example" -Recurse -ErrorAction Ignore | ||
& git clone --depth=1 https://github.com/CHANGEME/example.git "$Env:USERPROFILE\.vim\pack\plugins\start\example" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.