denon is the deno replacement for nodemon providing a feature packed and easy to use experience.
denon does not require any additional changes to your code or method of development. denon
is a replacement wrapper for deno
. To use denon
,replace the word deno
on the command line when executing your script.
Denon provides most of the features you would expect of a file watcher and more.
- Automatically restart your deno projects
- Drop-in replacement for
deno
executable - Extensive configuration options with script support
- Configurable file watcher with support for filesystem events and directory walking
- Ignoring specific files or directories with glob patterns
- Not limited to deno projects with a powerful script configuration
To install denon simply enter the following into a terminal:
$ deno install --allow-read --allow-run --allow-write -f --unstable https://deno.land/x/denon/denon.ts
⚠️ Make sure you are usingdeno
version^1.0.1
to install this executable. You can upgrade runningdeno upgrade
.
denon wraps your application, so you can pass all the arguments you would normally pass to your app:
$ denon run app.ts
you can pass arguments to deno:
$ denon run --allow-env app.ts
and even to your application:
$ denon run --allow-env app.ts --arg-for-my-app
you can run scripts declared in config:
$ denon [script name]
and you can see which script are available in your config:
$ denon
to see what else you can do with deno CLI use the help flag:
$ denon --help
In zsh, you can install autocompletion with:
echo '. <(denon --completion)' >> ~/.zshrc
In bash:
denon --completion >> ~/.config/denon.completion.sh
echo 'source ~/.config/denon.completion.sh' >> ~/.bash_profile
In fish:
echo 'denon --completion-fish | source' >> ~/.config/fish/config.fish
denon is designed to be simple but also extremely configurable to fit your project needs. It supports both json and yaml for the configuration file. The configuration options in yaml is the same as json making it compatible.
to create a basic configuration in the root directory of your project file you can run:
$ denon --init
this will create a basic denon.json
file:
{
"scripts": {
"start": "app.js"
}
}
You can use a JSON schema to have type checking on your configuration. Simply add:
{
"$schema": "https://deno.land/x/denon/schema.json",
"scripts": { /* */ }
}
⚠️ This feature going under development, so it might change
denon takes inspiration from the awesome velociraptor module in the way it handles scripts.
Scripts are declared inside the scripts
object and are identified by a name:
{
"scripts": {
// they all resolve to `deno run app.ts` when you run `denon start`
"start": "app.ts",
// OR
"start": "run app.ts",
// OR
"start": "deno run app.ts"
}
}
Scripts can also be defined by a complex object:
{
"scripts": {
"start": {
"cmd": "deno run app.ts",
// with an optional description that
// is shown when you run `denon` to list
// all the scripts
"desc": "Run the main server.",
// available options...
// they are described in the next paragraph
"allow": [
"env",
"watch",
],
"unstable": true
// running `denon start` will resolve in
// deno run --allow-env --allow-watch --unstable app.ts
}
}
}
Options can be script specific or be declared as global in the root of the config file.
Environment variables can be provided as an object and are passed directly to the child process.
{
// globally applied to all scripts
"env": {
"TOKEN": "SUPER SECRET TOKEN",
},
"scripts": {
"start": {
"cmd": "deno run app.ts",
"desc": "Run the main server.",
"env": {
"PORT": 3000
}
}
}
}
Permission can be granted to child processes.
{
// globally applied to all scripts
"allow": {
"read": "/etc", // --allow-read=/etc
"env": true // --allow-env
},
"scripts": {
"start": {
"cmd": "deno run app.ts",
"desc": "Run the main server.",
"allow": [
"run", // --allow-run
"net", // --allow-net
]
}
}
}
Load import map file. Take a look a at the official docs for additional info.
⚠️ This feature in unstable in the current version of the deno executable.
{
"scripts": {
"start": {
"cmd": "deno run app.ts",
"desc": "Run the main server.",
"importmap": "importmap.json"
}
}
}
Load tsconfig.json configuration file:
{
"scripts": {
"start": {
"cmd": "deno run app.ts",
"desc": "Run the main server.",
"tsconfig": "tsconfig.json"
}
}
}
Enable if the script is using unstable features of deno stdlib:
{
"scripts": {
"start": {
"cmd": "deno run app.ts",
"desc": "Run the main server.",
"unstable": true
}
}
}
Activate inspector on host:port
. If inspectBrk
is used the executions breaks at the start of the user script:
{
"scripts": {
"start": {
"cmd": "deno run app.ts",
"desc": "Run the main server.",
"inspect": "localhost:9229",
// OR
"inspectBrk": "localhost:9229"
}
}
}
Check the specified lock file:
{
"scripts": {
"start": {
"cmd": "deno run app.ts",
"desc": "Run the main server.",
"lock": "lock.json"
}
}
}
Load certificate authority from PEM encoded file:
{
"scripts": {
"start": {
"cmd": "deno run app.ts",
"desc": "Run the main server.",
"cert": "cert.pem"
}
}
}
Set log level: (possible values: debug
, info
)
{
"scripts": {
"start": {
"cmd": "deno run app.ts",
"desc": "Run the main server.",
"log": "debug" // or "info"
}
}
}
File watcher options:
{
"scripts": { /* */ },
"watcher": {
// The number of milliseconds after the last change.
"interval": 350,
// The file extensions that it will scan for.
"exts": ["js", "ts", "json"],
// The globs that it will scan for.
"match": ["*.*"],
// The globs that it will not scan for.
"skip": ["*/.git/*"],
// Use the legacy file monitoring algorithm. (walking)
"legacy": false
}
}
Internal logger options:
{
"scripts": { /* */ },
"logger": {
// Clear screen after every restart.
"fullscreen": false,
// Output only errors
"quiet": false,
// Output debug messages
"debug": true,
}
}
Pull request, issues and feedback are very welcome. Code style is formatted with deno fmt
and commit messages are done following Conventional Commits spec.
Copyright 2020-present, the denosaurs team. All rights reserved. MIT license.