fix: address PR reviews, add scheduler Windows tasks and Pester coverage
This commit is contained in:
+54
-22
@@ -26,20 +26,56 @@ if (Test-Path (Join-Path $ScriptDir "..\skillopt_sleep")) {
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $RepoRoot) {
|
||||
Write-Error "[sleep] ERROR: could not locate the skillopt_sleep package. Set SKILLOPT_SLEEP_REPO to the repo root."
|
||||
exit 1
|
||||
$argsList = @($args)
|
||||
if ($argsList.Count -eq 0) {
|
||||
$argsList = @("status")
|
||||
}
|
||||
|
||||
if ($RepoRoot) {
|
||||
$Py = ""
|
||||
if ($env:SKILLOPT_SLEEP_PYTHON) {
|
||||
$Py = $env:SKILLOPT_SLEEP_PYTHON
|
||||
} else {
|
||||
foreach ($cand in @("python3", "python", "py")) {
|
||||
$cmd = Get-Command $cand -ErrorAction SilentlyContinue
|
||||
if ($cmd) {
|
||||
$ver = & $cand -c "import sys; print('%d%d' % sys.version_info[:2])" 2>$null
|
||||
if ($ver -and [int]$ver -ge 310) {
|
||||
$Py = $cand
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $Py) {
|
||||
[Console]::Error.WriteLine("[sleep] ERROR: need Python >= 3.10 (found none).")
|
||||
exit 1
|
||||
}
|
||||
|
||||
Set-Location $RepoRoot
|
||||
& $Py -m skillopt_sleep $argsList
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
|
||||
# No source checkout found — fall back to an installed engine.
|
||||
|
||||
# Fallback 1: skillopt-sleep CLI on PATH (uv tool install / pipx / pip install).
|
||||
$cliCmd = Get-Command "skillopt-sleep" -ErrorAction SilentlyContinue
|
||||
if ($cliCmd) {
|
||||
& skillopt-sleep $argsList
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
|
||||
# Fallback 2: importable as a module (pip install into the active Python).
|
||||
$Py = ""
|
||||
if ($env:SKILLOPT_SLEEP_PYTHON) {
|
||||
$Py = $env:SKILLOPT_SLEEP_PYTHON
|
||||
} else {
|
||||
foreach ($cand in @("python3", "python", "py")) {
|
||||
$cmd = Get-Command $cand -ErrorAction SilentlyContinue
|
||||
if ($cmd) {
|
||||
$ver = & $cand -c "import sys; print('%d%d' % sys.version_info[:2])" 2>$null
|
||||
if ($ver -and [int]$ver -ge 310) {
|
||||
foreach ($cand in @("python3", "python", "py")) {
|
||||
$cmd = Get-Command $cand -ErrorAction SilentlyContinue
|
||||
if ($cmd) {
|
||||
$ver = & $cand -c "import sys; print('%d%d' % sys.version_info[:2])" 2>$null
|
||||
if ($ver -and [int]$ver -ge 310) {
|
||||
$hasModule = & $cand -c "import skillopt_sleep" 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$Py = $cand
|
||||
break
|
||||
}
|
||||
@@ -47,16 +83,12 @@ if ($env:SKILLOPT_SLEEP_PYTHON) {
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $Py) {
|
||||
Write-Error "[sleep] ERROR: need Python >= 3.10 (found none)."
|
||||
exit 1
|
||||
if ($Py) {
|
||||
& $Py -m skillopt_sleep $argsList
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
|
||||
$argsList = @($args)
|
||||
if ($argsList.Count -eq 0) {
|
||||
$argsList = @("status")
|
||||
}
|
||||
|
||||
Set-Location $RepoRoot
|
||||
# Run using the call operator
|
||||
& $Py -m skillopt_sleep $argsList
|
||||
[Console]::Error.WriteLine("[sleep] ERROR: could not locate the skillopt_sleep package.")
|
||||
[Console]::Error.WriteLine("[sleep] Install it with 'uv tool install skillopt' or 'pip install skillopt',")
|
||||
[Console]::Error.WriteLine("[sleep] or set SKILLOPT_SLEEP_REPO to a clone of the SkillOpt repo.")
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user