Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more

mod

Build Coverage Status nest badge GitHub

mod is a command line tool to quickly scaffold a new Deno module. It requires deno and optionally git.

Try it without installing anything:

Bash/Zsh

deno run \
--allow-read=./my_deno_module \
--allow-run=git \
--allow-write=./my_deno_module \
https://deno.land/x/mod@v2.2.6/mod.ts \
--name my_deno_module

PowerShell

deno run `
--allow-read=./my_deno_module `
--allow-run=git `
--allow-write=./my_deno_module `
https://deno.land/x/mod@v2.2.6/mod.ts `
--name my_deno_module

Table of Contents

Installation

Install the latest stable release from deno.land (or nest.land):

deno install --allow-read --allow-run=git --allow-write -n mod https://deno.land/x/mod@v2.2.6/mod.ts

Or install the latest unstable (unreleased) version from GitHub:

deno install --allow-read --allow-run=git --allow-write -n mod https://raw.githubusercontent.com/GJZwiers/mod/main/mod.ts

To upgrade, run the command with a new version number and include -f.

Permissions

mod requires the following permissions

  • read: to check if files already exists before writing.
  • run=git: to run git commands, more specifically git init
  • write: to make files as part of the module initialization.

Usage

mod

This will create the following file structure in the current working directory:

.
β”œβ”€β”€ .gitignore
β”œβ”€β”€ deps.ts
β”œβ”€β”€ dev_deps.ts
β”œβ”€β”€ mod.ts

Note that mod does not overwrite files unless --force is used explicitly. This means the program can also be used to β€˜fill in the blanks’ in a directory where not all of the files above are present yet.

Also note that mod does not perform editor-specific setups such as enabling Deno in VS Code via .vscode/settings.json.

If git is installed on the machine then git init will be run as well.

To create the new module in a new directory:

mod --name my_deno_module

This will create the following file and directory structure:

.
β”œβ”€β”€ my_deno_module
|   β”œβ”€β”€ .gitignore
|   β”œβ”€β”€ deps.ts
|   β”œβ”€β”€ dev_deps.ts
|   β”œβ”€β”€ mod.ts

mod can also create other files along with the basics, such as a pipeline:

mod -n my_deno_module --ci
.
β”œβ”€β”€ my_deno_module
|   β”œβ”€β”€ .github
|   |   β”œβ”€β”€ workflows
|   |   |   β”œβ”€β”€ build.yaml
|   β”œβ”€β”€ .gitignore
|   β”œβ”€β”€ deps.ts
|   β”œβ”€β”€ dev_deps.ts
|   β”œβ”€β”€ mod.ts

You can also initialize with JavaScript:

mod --js
.
β”œβ”€β”€ .gitignore
β”œβ”€β”€ deps.js
β”œβ”€β”€ dev_deps.js
β”œβ”€β”€ mod.js

Options

mod can create other files with the module, such as an import map or a Deno configuration file. To see what options and flags are available use mod --help if you have the CLI installed or deno run https://deno.land/x/mod@v2.2.6/mod.ts --help

Contributing

Bug reports and feature requests are very welcome!