nodejs / nodejs/node

--watch should monitor replaced files

未关闭
#51,621 12 条评论 16 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

feature request watch-mode
主要语言
JavaScript
星标
122k
派生
37.4k
平均合并
4 天 3 小时
30 天内合并 PR
272

描述

What is the problem this feature will solve?

Currently, --watch watches an inode and not necessarily what the user might consider a "file". This can cause confusion on systems that write to disk by deleting the old file and then creating a new one.

For example, when using Docker Compose's watch mode, the watched file is first deleted. When a new file is created Node currently fails to restart on file changes, as node is still watching the inode of the deleted file, and doesn't react to the new file being created.

What is the feature you are proposing to solve the problem?

While this behavior makes sense for the lower-level and more "raw" fs.watch(), perhaps the more general --watch behavior can be expanded to be smarter about detecting replaced files. Alternatively, a new flag can be introduced with this behavior.

What alternatives have you considered?

Other alternatives require using one of the different file watcher libs. That seems like a step down from the otherwise awesome native watch feature.

Docker Compose Issue: [BUG] Compose Watch With “node –watch” Only Reloads First Time
Docker Issue: node --watch doesn't work well within a container

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 Node.js 的 --watch 实现以及 issue 中描述的 fs.watch 行为开始。重现 Docker Compose 风格的删除并重新创建序列,然后确定是否应扩展现有行为,或通过新的 flag 将其暴露出来。当被监视的文件被替换时,--watch 能够可靠地作出反应,并且包含针对替换情况的测试覆盖,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, nodejs
领域
tooling
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
活跃
描述清晰度
需要澄清
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。