FsHotWatch.FileCommand
0.7.0-alpha.9
dotnet add package FsHotWatch.FileCommand --version 0.7.0-alpha.9
NuGet\Install-Package FsHotWatch.FileCommand -Version 0.7.0-alpha.9
<PackageReference Include="FsHotWatch.FileCommand" Version="0.7.0-alpha.9" />
<PackageVersion Include="FsHotWatch.FileCommand" Version="0.7.0-alpha.9" />
<PackageReference Include="FsHotWatch.FileCommand" />
paket add FsHotWatch.FileCommand --version 0.7.0-alpha.9
#r "nuget: FsHotWatch.FileCommand, 0.7.0-alpha.9"
#:package FsHotWatch.FileCommand@0.7.0-alpha.9
#addin nuget:?package=FsHotWatch.FileCommand&version=0.7.0-alpha.9&prerelease
#tool nuget:?package=FsHotWatch.FileCommand&version=0.7.0-alpha.9&prerelease
FsHotWatch.FileCommand
Plugin that runs a custom command when files matching a pattern change. Register multiple instances for different file patterns.
Why
Sometimes you want to run a specific command when certain files change --
type-check your .fsx scripts, validate SQL migrations, regenerate
code from .proto files, etc. FileCommand lets you do this without
writing a full plugin.
How it works
- You save a file
- FileCommandPlugin checks if the file matches its pattern
- If it matches, it runs the configured command
- Success/failure is reported to the error ledger
Configuration
In .fshw.json:
{
"fileCommands": [
{
"pattern": "*.fsx",
"command": "dotnet",
"args": "fsi --typecheck-only"
},
{
"pattern": "*.sql",
"command": "sqlfluff",
"args": "lint"
}
]
}
| Field | Type | Default | Description |
|---|---|---|---|
name |
string |
derived from pattern |
Plugin identifier. Required when afterTests is set. |
pattern |
string |
— | File pattern to match. *.ext matches any path ending with .ext. A literal filename (e.g. coverage-ratchet.json) matches only files with that exact basename. |
afterTests |
true or string[] |
— | Fire after a test run completes. true fires on any completed run; an array fires only when all named projects complete. Requires name. |
command |
string |
"echo" |
Command to run when triggered. |
args |
string |
"" |
Arguments to the command. |
At least one of pattern or afterTests must be specified. Both can
be set on the same entry — e.g. a coverage ratchet that should re-run
whenever tests complete OR when its config file changes:
{
"fileCommands": [
{
"name": "coverage-ratchet",
"pattern": "coverage-ratchet.json",
"afterTests": true,
"command": "dotnet",
"args": "tool run coverageratchet"
}
]
}
When pattern targets a non-source file (e.g. *.ratchet.json or
coverage-ratchet.json), the daemon automatically extends its file
watcher to cover that pattern so real edits trigger the plugin.
Environment variables on afterTests commands
The following environment variables are set on every afterTests command:
FSHW_RAN_FULL_SUITE:"true"if every project in the test run executed without an impact filter (i.e., the entire test suite ran),"false"if at least one project was filtered to a subset. Use this to gate baseline refreshes or threshold tightening — partial runs should not lower a coverage baseline or tighten a ratchet.
CLI
# Force a plugin to re-run, clearing its cached state
fshw rerun coverage-ratchet
# Query a plugin's last-run status
fshw coverage-ratchet-status
Programmatic usage
open FsHotWatch.PluginFramework
open FsHotWatch.FileCommand.FileCommandPlugin
// Type-check .fsx scripts when they change
let trigger: CommandTrigger =
{ FilePattern = Some(fun f -> f.EndsWith(".fsx"))
AfterTests = None }
daemon.RegisterHandler(
create
(PluginName.create "scripts") // plugin name
trigger // CommandTrigger (pattern and/or afterTests)
"dotnet" // command
"fsi --typecheck-only build.fsx" // args
repoRoot // for resolving relative arg-file paths
None // timeoutSec (None → no timeout)
)
For the combined trigger case (fires on file changes AND test completion):
let trigger: CommandTrigger =
{ FilePattern = Some(fun f -> f.EndsWith(".ratchet.json"))
AfterTests = Some AnyTest }
See the FullPipelineExample for a complete setup.
Install
dotnet add package FsHotWatch.FileCommand
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- FSharp.Core (>= 10.1.203)
- FsHotWatch (>= 0.8.0-alpha.12)
- System.Security.Cryptography.Xml (>= 10.0.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.7.0-alpha.9 | 50 | 4/29/2026 |
| 0.7.0-alpha.8 | 55 | 4/25/2026 |
| 0.7.0-alpha.7 | 55 | 4/23/2026 |
| 0.7.0-alpha.3 | 56 | 4/18/2026 |
| 0.7.0-alpha.2 | 55 | 4/15/2026 |
| 0.6.0-alpha.1 | 54 | 4/12/2026 |
| 0.5.0-alpha.1 | 52 | 4/12/2026 |
| 0.3.0-alpha.1 | 61 | 4/8/2026 |
| 0.1.0-alpha.1 | 62 | 4/3/2026 |