You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Deno.json任务是否支持类似npm的pre*、post*前置/后置脚本?

Deno Tasks 是否支持 pre*/post* 自动脚本?

Deno 目前的 deno.json 任务系统不支持 npm 那种自动触发 pre*/post* 前置/后置脚本的功能。

你现在用的手动调用方式是当前的标准解决方案——直接在主任务里显式执行前置任务,比如你在 test 任务里写的 deno task pretest && deno test ...,这种写法完全没问题,可以满足需求。

你的配置示例:

{
  "tasks": {
    "start": "deno run -A --unstable --watch=static/,routes/ dev.ts",
    "pretest": "jq -s '.[0] * .[1]' import_map.json unit.test.import_map.json > unit.test.import_map.gen.json",
    "test": "deno task pretest && deno test --allow-read --watch --import-map=unit.test.import_map.gen.json"
  },
  "importMap": "./import_map.json",
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "preact"
  }
}

内容的提问来源于stack exchange,提问作者Norfeldt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 15:34:53