Repository navigation
Install real Windows timers via schtasks - #1
Merged
Merged
Conversation
holt schedule and a routine's --at previously did nothing useful on Windows: they saved the job, then printed a cron line the OS cannot use. Windows now gets a .cmd wrapper in ~/.holt/tasks/ registered with schtasks, mirroring how macOS gets a launchd plist. The wrapper exists so the command never has to survive schtasks /TR quoting, which mangles embedded quotes and breaks on any task phrase or path containing a space. Entry generation stays pure (buildWindowsScript, buildSchtasksArgs), so the Windows path is testable from a Mac. 14 checks cover the cmd quoting rules, CRLF endings, notify ordering, and /ST zero-padding. Also deduplicates the launchd and cron install/remove logic, which routine.ts had copied from schedule.ts, behind installForPlatform and removeForPlatform. Routines therefore get Windows support for free, and the two commands can no longer drift apart.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
holt scheduleand a routine's--atdid nothing useful on Windows. They saved the job to the store, then printed a cron line the OS cannot use, soholt schedule listshowed a timer that was never going to fire.Windows now gets a real Task Scheduler entry.
How
A
.cmdwrapper is written to~/.holt/tasks/<id>.cmdand registered withschtasks, mirroring how macOS gets a launchd plist.The wrapper exists specifically so the command never has to survive
schtasks /TRquoting./TRtakes a single string and mangles embedded quotes, which breaks the moment a task phrase or a path underProgram Filescontains a space. A batch file has none of that problem.Entry generation stays pure (
buildWindowsScript,buildSchtasksArgs,cmdQuote), which is what makes the Windows path testable from a Mac at all.Also: deduplication
routine.tshad its own copies ofinstallDarwin,installLinux,currentCrontab,writeCrontab, and both remove functions, copy-pasted fromschedule.ts. Both now go throughinstallForPlatform/removeForPlatform.Routines get Windows support for free, and the two commands can no longer drift apart. Net 72 lines removed from
routine.ts.Testing
New
scripts/scheduler.test.ts, wired intonpm test. 14 checks covering cmd quoting rules, doubled-quote escaping, CRLF endings,cd /d, notify ordering after the errorlevel guard, routinerunArgs, and/STzero-padding.Verified by hand on macOS that both round-trips still work after the refactor:
schedule add/removeandroutine add --at/removeeach create and then fully clean up their plist and launchd registration.Not verified on real Windows hardware. The pure builders are pinned by tests, but nobody has watched
schtasksaccept the argv on an actual machine.Docs
README,
docs/INSTALL.md, and theauditskill no longer say Windows scheduling is unsupported. The remaining honest caveat, now documented: a scheduled run is skipped rather than caught up if the machine was asleep at that time.