wheels watch
Watch Wheels application files for changes and automatically reload the application.
Synopsis
Description
The wheels watch
command monitors your application files for changes and automatically triggers actions like reloading the application, running tests, or executing custom commands. This provides a smooth development workflow with instant feedback.
Arguments
includeDirs
Comma-delimited list of directories to watch
controllers,models,views,config,migrator/migrations
excludeFiles
Comma-delimited list of file patterns to ignore
(none)
interval
Interval in seconds to check for changes
1
reload
Reload framework on changes
true
tests
Run tests on changes
false
migrations
Run migrations on schema changes
false
command
Custom command to run on changes
(none)
debounce
Debounce delay in milliseconds
500
Note: In CommandBox, boolean flags are specified with --flagname
and value parameters with paramname=value
.
Examples
Basic file watching
Watches default directories for changes and reloads the application
Watch with tests
Runs tests automatically when files change
Watch specific directories
Exclude file patterns
Watch with all features
Custom command on changes
Adjust check interval
Disable reload but run tests
What It Does
The watch command starts with:
An initial scan of all watched directories to establish baseline
Displays count of files being monitored
Checks for changes at the specified interval
When changes are detected:
With
--reload
: Reloads the applicationWith
--tests
: Runs tests (smart filtering based on changed files)With
--migrations
: Runs migrations if schema files changedWith
--command
: Executes the specified command
Output Example
File Exclusion
The excludeFiles
parameter supports patterns:
*.txt
- Exclude all .txt files*.log
- Exclude all .log filestemp.cfc
- Exclude specific file nameMultiple patterns:
excludeFiles="*.txt,*.log,temp.*"
Smart Test Running
When --tests
is enabled, the command intelligently determines which tests to run:
Changes to models run model tests
Changes to controllers run controller tests
Multiple changes batch test execution
Migration Detection
With --migrations
enabled, the command detects:
New migration files in
/migrator/migrations/
Changes to schema files
Automatically runs
wheels dbmigrate up
Performance Considerations
Initial scan time depends on project size
Use
includeDirs
to limit scopeUse
excludeFiles
to skip large filesAdjust
interval
for less frequent checksUse
debounce
to batch rapid changes
Common Workflows
Development Workflow
Frontend + Backend
Test-Driven Development
Database Development
Best Practices
Start Simple: Use
wheels watch
with defaults firstAdd Features Gradually: Enable tests, migrations as needed
Optimize Scope: Use
includeDirs
for faster performanceExclude Wisely: Skip log files, temp files, etc.
Batch Changes: Increase debounce for multiple file saves
Troubleshooting
High CPU Usage: Reduce check frequency with
interval
Missed Changes: Check excluded patterns
Reload Errors: Ensure reload password is configured
Test Failures: Run tests manually to debug
Notes
Changes are tracked by file modification time
New files are automatically detected
Deleted files are removed from tracking
Press Ctrl+C to stop watching
See Also
wheels reload - Manual application reload
wheels test run - Run tests manually
wheels dbmigrate up - Run migrations
Last updated
Was this helpful?