使用VSCODE API观看项目依赖关系
我正在编写VSCODE扩展程序,我需要一种方法来知道何时项目获得新的依赖性以触发某些操作。为此,我决定使用“ fs.watchfile”观看package.json文件。但是问题在于,FS仅在保存文件后才看到更改,并且需要一两秒钟。此外,如果用户手动添加新的依赖项。我想知道VSCODE是否具有一些内部API,可以比FS做得更好。
I am writing a VSCode extension and I need a way to know when a project gets a new dependency to trigger some action. For that, I decided to watch package.json file using 'fs.watchFile'. But the problem is that fs sees the change only after saving the file and it takes a second or two. Moreover, if a user adds a new dependency manually to package.json there is no change event until the user saves it. I wonder if VSCode has some internal API that will do it better than fs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
VSCODE具有
vscode.workspace.createfilesystemwatcher
的不错的实用程序。它比FS实现更好,因为当文件保存之前“肮脏”时也会触发它。可能的实施是:VSCode has a nice utility for that
vscode.workspace.createFileSystemWatcher
. It's better than fs implementation because it is also triggered when the file is 'dirty' before it is saved. Possible implementation is: