【问题标题】:How to use - 'deno fmt' in denon如何使用 - denon 中的“deno fmt”
【发布时间】:2020-09-24 22:12:11
【问题描述】:

我将"fmt": true 添加到denon.json 文件中,以便在保存文件时运行自动格式化。但这不起作用。保存文件时如何运行自动格式化?

【问题讨论】:

  • 我会建议使用 pre-commit hook 更好的性能。或自动保存 vscode。
  • 添加您的配置以供其他人参考。

标签: deno


【解决方案1】:

目前,运行deno fmt时似乎不能有watch选项,所以我有以下内容:

{
  "$schema": "https://deno.land/x/denon@2.4.7/schema.json",
  "scripts": {
    "start": {
      "cmd": "deno run app.ts"
    },
    "format": {
      "cmd": "deno fmt",
      "watch": false
    }
  }
}

当然,现在我需要手动运行denon format :(

【讨论】:

    【解决方案2】:

    基于 Denon 的 documentationfmt 选项不存在,因此它什么也不做。

    您可以为此添加一个单独的脚本到denon.json,并与您的其他脚本同时运行。允许标志需要为空,使用它作为denon format

    "scripts": {
      "format": {
        "cmd": "deno fmt",
        "desc": "Format the code.",
        "allow": []
      }
      ...
    }
    

    【讨论】:

      猜你喜欢
      • 2022-12-15
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 2020-09-16
      • 1970-01-01
      • 2022-12-24
      • 2020-09-01
      • 2020-10-31
      相关资源
      最近更新 更多