Tricks and command-line utilities to automatically reload applications.
Overview
Most modern application development frameworks have a built-in feature to make the development workflow easy by automatically reloading the application whenever source code is changed.
However, there are occasions you still need to manually run and debug applications when source files are changed.
In this article, let’s explore commands and utilities we can use to make this process easier. The utilities mentioned here can be used for many languages. For demonstration, I am going to use a mix of different languages.
nodemon
Let’s start with nodemon
which is a tool that helps develop Node.js
based applications by automatically restarting the node application when file changes in the directory are detected.
However, nodemon
is not limited to Node.js
.
Node.js
E.g. for a Node.js
application (app.js
), you can just run the command
nodemon app.js
You can also watch multiple directories. E.g. to watch for the app
and libs
folders.
nodemon --watch app --watch libs app/server.js
Or to ignore particular folders,
nodemon --ignore lib/ --ignore tests/ app/server.js
Note: There are many more features available. Do check out the documentation.
Python
nodemon --exec "python" ./app.py
Rust
nodemon --exec "cargo run" src/main.rs
Note: For a more native option, check out cargo-watch
.