Usage with config
Using RustyWatch with configuration.
With RustyWatch, you can manage multiple projects effortlessly using a simple configuration file.
Here’s how to setup and use it with a rustywatch.yaml file.
Project structure example
Your project directory might look like this.
.├── rustywatch.yaml└── examples/ ├── go-project ├── rust-project └── nodejs-projectSample rustywatch.yaml configuration.
workspaces: - dir: 'examples/go-project' cmd: - echo "Building go-project..." - go build bin_path: './go-project' # relative to workspace dir env_file: '.env' - dir: 'examples/nodejs-project' cmd: npm start env_file: '/.env' # loads from project root - dir: 'examples/rust-project' cmd: - echo "Building rust-project..." - cargo build bin_path: './target/debug/rust-project' # relative to workspace dir ignore: - 'target/'Explanation the configuration.
dir: The project directory to watch. Commands automatically execute in this directory.cmd: The commands to run for each project. Can be a single command or an array of commands.bin_path: The path to the binary executable file, relative to the workspace directory. For example, in a Rust project withdir: 'my-app', usebin_path: './target/debug/my-app'instead ofbin_path: 'my-app/target/debug/my-app'.ignore(optional): Files or directories that should be excluded from being monitored by RustyWatch. Paths are relative to the workspace directory.env_file(optional): Path to a.envfile containing environment variables. Use a relative path (e.g.,.env) to load from the workspace directory, or prefix with/(e.g.,/.env) to load from the project root.
Example Projects
Go Project:
- Located in
examples/go-project - Commands:
go build(runs inexamples/go-project/) - Binary location:
./go-project(relative to workspace dir)
Node.js Project:
- Located in
examples/nodejs-project - Commands:
npm start(runs inexamples/nodejs-project/)
Rust Project:
- Located in
examples/rust-project - Commands:
cargo build(runs inexamples/rust-project/) - Binary location:
./target/debug/rust-project(relative to workspace dir) - The
target/directory is ignored to prevent unnecessary rebuilds.
Usage
Once you have your rustywatch.yaml configured. simply run:
rustywatchRustyWatch will handle everything automatically, building and watching your multiple projects as defined in the configuration file.
For more examples please check this out: https://github.com/ak9024/rustywatch/tree/main/examples.