Denon -- 类似于Node.js的nodemon自动重启工具

Denon是一款用于简化Deno应用部署和管理的工具。它支持通过配置文件来定义项目的启动脚本和参数,允许开发者轻松地使用单个命令启动复杂的Deno应用。Denon支持多种配置选项,包括环境变量、权限管理、导入映射、日志级别等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装Denon

deno install --allow-read --allow-run --allow-write --allow-net -f -q --unstable https://deno.land/x/denon@2.4.0/denon.ts

用法
可以直接使用denon命令运行程序,可以传递deno命令支持的所有参数:

$ denon run --allow-env app.ts --arg-for-my-app

更常用来运行script:

$ denon [script name]

配置
支持json和yaml两种格式的配置文件。

运行如下命令创建denon.json文件:

$ denon --init

生成的文件内容如下:

{
  // optional but highly recommended
  "$schema": "https://deno.land/x/denon/schema.json",
  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "run my app.ts file"
    }
  }
}

也可以使用denon.yml文件:

scripts:
  start:
    cmd: "deno run app.ts"
    desc: "run my app.ts file"

Script选项
简单的scripts:

{
  "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"
  }
}

也可以定义复杂的script对象。denon script支持环境变量、权限、tsconfig、imap、log等选项,可以配置是否监视文件,详细信息请查阅官方文档,一些选项的含义可以查看下节Deno CLI。

{
  // globally applied to all scripts
  // now denon will essentialy be a script runner
  "watch": false

  // globally applied to all scripts
  "env": {
    "TOKEN": "SUPER SECRET TOKEN",
  },

  // globally applied to all scripts
  // as object ...
  "allow": {
    "read": "/etc,/tmp", // --allow-read=/etc,/tmp
    "env": true     // --allow-env
  },
  // ... or as array
  "allow": [
    "run", // --allow-run
    "net" // --allow-net
  ]

  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "Run the main server.",
      "importmap": "importmap.json",
      "tsconfig": "tsconfig.json",
      "log": "debug", // or "info"
      "unstable": true,
      // you can still enable watch on a script-by-script basis
      "watch": true,

      "inspect": "127.0.0.1:9229",
      // OR
      "inspectBrk": "127.0.0.1:9229"

      "env": {
        "PORT": 3000
      },

      // specific for a single script
      // as object ...
      "allow": {
        "read": "/etc,/tmp", // --allow-read=/etc,/tmp
        "env": true     // --allow-env
      },
      // ... or as array
      "allow": [
        "run", // --allow-run
        "net" // --allow-net
      ]
    }
  }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值