Skip to content

Commit 1535499

Browse files
committed
🚜 [refactor] Make directory creation testable and harden startup/redirection logic
- Add $script:CreateDirectoryDelegate and replace direct New-Item calls with the delegate to allow deterministic, testable directory creation - Harden console-redirection detection: Test-ColorScriptTextEmission now safely queries [Console]::IsOutputRedirected (try/catch) and uses that state for PassThru/pipeline decisions - Rework Invoke-ColorScriptsStartup to evaluate auto-show override, handle Test-ConsoleOutputRedirected failures safely, skip startup in CI/ServerRemoteHost when appropriate, and emit a verbose message when an override is suppressed due to redirection 🧪 [test] Update tests and stubs to support new delegates and silence unused-parameter diagnostics - Expand C# StubHost/RawUI expression-bodied members to explicit getters/setters and full method bodies for compatibility and coverage stability - Add explicit [void] casts to mocked parameters/locals and updated Mock blocks to consume args (silence unused warnings and make intent explicit) - Introduce tests that set/reset $script:CreateDirectoryDelegate and simulate delegate failure, restoring the original delegate in finally blocks 🧹 [chore] Normalize CI/dependabot YAML formatting - Fix indentation/formatting in .github/dependabot.yml and .github/workflows/publish.yml for consistent YAML style (no behavior changes) 🔧 [build] Tighten test coverage policy and refine reporting verbosity - Increase scripts/Test-Coverage.ps1 default MinimumCoverage from 70 to 95 to enforce higher coverage - Expand/standardize Show verbosity ValidateSet (add Minimal/Detailed) and refine mapping to Pester output verbosity 📝 [docs] Bump module and help manifest versions - Update ModuleVersion and ReleaseNotes header in ColorScripts-Enhanced.psd1 and UICultureVersion in HelpInfo.xml to 2025.10.29.1629 Signed-off-by: Nick2bad4u <20943337+Nick2bad4u@users.noreply.github.com>
1 parent 8fb8fda commit 1535499

11 files changed

Lines changed: 254 additions & 114 deletions

.github/dependabot.yml

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -10,68 +10,68 @@
1010

1111
version: 2
1212
updates:
13-
- package-ecosystem: github-actions
14-
cooldown:
15-
default-days: 3
16-
include: ["*"]
17-
directory: /
18-
schedule:
19-
interval: quarterly
20-
time: "05:30"
21-
timezone: "America/Detroit"
22-
assignees: ["Nick2bad4u"]
23-
allow:
24-
# Allow both direct and indirect updates for all packages
25-
- dependency-type: "all"
26-
labels:
27-
- "github-actions"
28-
- "dependabot"
29-
- "dependencies"
30-
commit-message:
31-
prefix: "[ci][skip-ci]"
32-
prefix-development: "[ci][skip-ci]"
33-
include: "scope"
34-
groups:
35-
github-actions:
36-
applies-to: version-updates
37-
patterns:
38-
- "*"
13+
- package-ecosystem: github-actions
14+
cooldown:
15+
default-days: 3
16+
include: ["*"]
17+
directory: /
18+
schedule:
19+
interval: quarterly
20+
time: "05:30"
21+
timezone: "America/Detroit"
22+
assignees: ["Nick2bad4u"]
23+
allow:
24+
# Allow both direct and indirect updates for all packages
25+
- dependency-type: "all"
26+
labels:
27+
- "github-actions"
28+
- "dependabot"
29+
- "dependencies"
30+
commit-message:
31+
prefix: "[ci][skip-ci]"
32+
prefix-development: "[ci][skip-ci]"
33+
include: "scope"
34+
groups:
35+
github-actions:
36+
applies-to: version-updates
37+
patterns:
38+
- "*"
3939

40-
- package-ecosystem: npm
41-
cooldown:
42-
default-days: 3
43-
include: ["*"]
44-
directory: /
45-
schedule:
46-
interval: quarterly
47-
assignees: ["Nick2bad4u"]
48-
versioning-strategy: increase
49-
allow:
50-
# Allow both direct and indirect updates for all packages
51-
- dependency-type: "all"
52-
ignore:
53-
- dependency-name: "electron-builder"
54-
versions: ["< 26.0.18"]
55-
- dependency-name: "electron-builder-squirrel-windows"
56-
versions: ["< 26.0.18"]
57-
# Ignore local workspace dependencies completely
58-
- dependency-name: "@shared/*"
59-
- dependency-name: "file:*"
40+
- package-ecosystem: npm
41+
cooldown:
42+
default-days: 3
43+
include: ["*"]
44+
directory: /
45+
schedule:
46+
interval: quarterly
47+
assignees: ["Nick2bad4u"]
48+
versioning-strategy: increase
49+
allow:
50+
# Allow both direct and indirect updates for all packages
51+
- dependency-type: "all"
52+
ignore:
53+
- dependency-name: "electron-builder"
54+
versions: ["< 26.0.18"]
55+
- dependency-name: "electron-builder-squirrel-windows"
56+
versions: ["< 26.0.18"]
57+
# Ignore local workspace dependencies completely
58+
- dependency-name: "@shared/*"
59+
- dependency-name: "file:*"
6060

61-
labels:
62-
- "npm"
63-
- "dependabot"
64-
- "dependencies"
65-
commit-message:
66-
prefix: "[dependency]"
67-
prefix-development: "[dev-dependency][skip-ci]"
68-
include: "scope"
69-
groups:
70-
npm-all:
71-
applies-to: version-updates
72-
patterns:
73-
- "*"
74-
# Exclude local packages from grouping
75-
exclude-patterns:
76-
- "@shared/*"
77-
- "file:*"
61+
labels:
62+
- "npm"
63+
- "dependabot"
64+
- "dependencies"
65+
commit-message:
66+
prefix: "[dependency]"
67+
prefix-development: "[dev-dependency][skip-ci]"
68+
include: "scope"
69+
groups:
70+
npm-all:
71+
applies-to: version-updates
72+
patterns:
73+
- "*"
74+
# Exclude local packages from grouping
75+
exclude-patterns:
76+
- "@shared/*"
77+
- "file:*"

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ jobs:
7474
id: setup-node
7575
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
7676
with:
77-
node-version: "22"
78-
cache: "npm"
77+
node-version: "22"
78+
cache: "npm"
7979

8080
- name: install dependency
8181
run: |

ColorScripts-Enhanced/ColorScripts-Enhanced.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
RootModule = 'ColorScripts-Enhanced.psm1'
1212

1313
# Version number of this module.
14-
ModuleVersion = '2025.10.29.0344'
14+
ModuleVersion = '2025.10.29.1629'
1515

1616
# Supported PSEditions
1717
CompatiblePSEditions = @('Desktop', 'Core')
@@ -172,7 +172,7 @@ Full documentation: https://github.com/Nick2bad4u/ps-color-scripts-enhanced
172172

173173
# ReleaseNotes of this module
174174
ReleaseNotes = @'
175-
Version 2025.10.29.0344:
175+
Version 2025.10.29.1629:
176176
- Enhanced caching system with OS-wide cache in AppData
177177
- 6-19x performance improvement
178178
- Cache stored in centralized location

ColorScripts-Enhanced/ColorScripts-Enhanced.psm1

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ function Initialize-SystemDelegateState {
123123
[Console]::Write($Text)
124124
}
125125
}
126+
127+
if (-not $script:CreateDirectoryDelegate) {
128+
$script:CreateDirectoryDelegate = {
129+
param([string]$Path)
130+
[System.IO.Directory]::CreateDirectory($Path)
131+
}
132+
}
126133
}
127134

128135
Initialize-SystemDelegateState
@@ -363,7 +370,7 @@ function Get-ColorScriptsConfigurationRoot {
363370

364371
try {
365372
if (-not (Test-Path -LiteralPath $resolved)) {
366-
New-Item -ItemType Directory -Path $resolved -Force -ErrorAction Stop | Out-Null
373+
(& $script:CreateDirectoryDelegate $resolved) | Out-Null
367374
}
368375
$script:ConfigurationRoot = $resolved
369376
return $script:ConfigurationRoot
@@ -845,12 +852,20 @@ function Test-ColorScriptTextEmission {
845852
[System.Collections.IDictionary]$BoundParameters
846853
)
847854

855+
$isRedirected = $false
856+
try {
857+
$isRedirected = [Console]::IsOutputRedirected
858+
}
859+
catch {
860+
$isRedirected = $false
861+
}
862+
848863
if ($ReturnText) {
849864
return $true
850865
}
851866

852867
if ($PassThru) {
853-
return $false
868+
return $isRedirected
854869
}
855870

856871
if ($PipelineLength -gt 1) {
@@ -861,7 +876,11 @@ function Test-ColorScriptTextEmission {
861876
return $true
862877
}
863878

864-
return $false
879+
if ($PipelineLength -gt 0) {
880+
return $isRedirected
881+
}
882+
883+
return $isRedirected
865884
}
866885

867886
function Get-PowerShellExecutable {
@@ -3329,19 +3348,6 @@ function Test-ConsoleOutputRedirected {
33293348
# Internal helper to honor startup preferences post-import
33303349
function Invoke-ColorScriptsStartup {
33313350
try {
3332-
# Fast-path: check environment conditions BEFORE loading configuration
3333-
if ($env:CI -eq 'true' -or $env:GITHUB_ACTIONS -eq 'true') {
3334-
return
3335-
}
3336-
3337-
if ($Host.Name -eq 'ServerRemoteHost') {
3338-
return
3339-
}
3340-
3341-
if (Test-ConsoleOutputRedirected) {
3342-
return
3343-
}
3344-
33453351
$autoShowOverride = $env:COLOR_SCRIPTS_ENHANCED_AUTOSHOW_ON_IMPORT
33463352
$overrideEnabled = $false
33473353
if ($autoShowOverride) {
@@ -3351,6 +3357,32 @@ function Invoke-ColorScriptsStartup {
33513357
}
33523358
}
33533359

3360+
$outputRedirected = $false
3361+
try {
3362+
$outputRedirected = Test-ConsoleOutputRedirected
3363+
}
3364+
catch {
3365+
$outputRedirected = $false
3366+
}
3367+
3368+
if (-not $overrideEnabled) {
3369+
if ($env:CI -eq 'true' -or $env:GITHUB_ACTIONS -eq 'true') {
3370+
return
3371+
}
3372+
3373+
if ($Host.Name -eq 'ServerRemoteHost') {
3374+
return
3375+
}
3376+
3377+
if ($outputRedirected) {
3378+
return
3379+
}
3380+
}
3381+
elseif ($outputRedirected) {
3382+
Write-Verbose 'Console output is redirected; skipping auto-show despite override.'
3383+
return
3384+
}
3385+
33543386
$configRoot = $null
33553387
try {
33563388
$configRoot = Get-ColorScriptsConfigurationRoot

ColorScripts-Enhanced/en-US/ColorScripts-Enhanced_f77548d7-23eb-48ce-a6e0-f64b4758d995_HelpInfo.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<SupportedUICultures>
55
<UICulture>
66
<UICultureName>en-US</UICultureName>
7-
<UICultureVersion>2025.10.29.0344</UICultureVersion>
7+
<UICultureVersion>2025.10.29.1629</UICultureVersion>
88
</UICulture>
99
</SupportedUICultures>
1010
</HelpInfo>

0 commit comments

Comments
 (0)