运行 nodemon 更改脚本

Run script on change in nodemon

是否可以 运行 使用 nodemon 更改脚本?

是否可以这样做:nodemon --watch src --exec yarn run my-script?

所以,理想情况下,我只想在 src 文件夹

中发生更改时 运行 脚本

in the Nodemon docs所示,您可以在nodemon.json中添加重启事件命令:

{
  "events": {
    "restart": "yarn my-script"
  }
}

只需在要执行的脚本两边加上引号即可:

nodemon --watch src --exec "yarn run my-script"