当前位置:网站首页>[node learning notes] the chokidar module realizes file monitoring
[node learning notes] the chokidar module realizes file monitoring
2022-07-07 02:35:00 【51CTO】
Preface
When developing cloud disk , Used Node.js Of chokidar The module monitors local files , Get the trigger event of file modification , Now let's introduce the knowledge points involved and the implementation process .
Knowledge point
chokidar.watch(paths, [options]) Return to one chokidar Construct listening instance
Parameters :paths
A string or an array , Describe the path of the monitored file or folder .
Event response
.add Triggered when adding a file
.addDir Triggered when adding a folder
.unlink Delete the corresponding file
.unlinkDir Delete the corresponding folder
.change Triggered when the file content changes
.all( except ready, raw, and error All event types except ) contain :add、addDir、unlink、unlinkDir、change
.ready Initialization complete
.raw Original event
.error Capture error
.unwatch(path / paths) Stop listening for incoming files / Folder
.close() Remove from the monitoring file / Close all listeners
.getWatched() Back here FSWatcher Objects of all paths on the file system being monitored by the instance
Sample code of listening file
matters needing attention
When realizing file listening , There is a problem of system compatibility , Some computers will not trigger file modification change, It triggered unlink The circumstances of the incident . therefore , stay unlink Added in the event , Trigger update when file exists .
That's what this issue is about chokidar The module realizes local file listening The share of , I hope I can help you .
In the next issue, I'll share more details about the actual combat , If you're interested in that , Welcome to pay attention to 、 Leaving a message. , Your support is my motivation !
边栏推荐
- This week's hot open source project!
- 【论文阅读|深读】RolNE: Improving the Quality of Network Embedding with Structural Role Proximity
- 3D laser slam: time synchronization of livox lidar hardware
- C#/VB. Net to delete watermarks in word documents
- [leetcode]Search for a Range
- 安全巡检的工作
- fiddler的使用
- MetaForce原力元宇宙佛萨奇2.0智能合约系统开发(源码部署)
- 写作系列之contribution
- [paper reading | deep reading] anrl: attributed network representation learning via deep neural networks
猜你喜欢
![leetcode:5. Longest palindrome substring [DP + holding the tail of timeout]](/img/62/d4d5428f69fc221063a4f607750995.png)
leetcode:5. Longest palindrome substring [DP + holding the tail of timeout]

unity中跟随鼠标浮动的面板,并可以自适应文字内容的大小

Processus général de requête pour PostgreSQL

Draco - glTF模型压缩利器

你不可不知道的Selenium 8种元素定位方法,简单且实用

dotConnect for DB2数据提供者

数论 --- 快速幂、快速幂求逆元

Integerset of PostgreSQL
![[paper reading | deep reading] anrl: attributed network representation learning via deep neural networks](/img/06/17acf9958228cce5d80ada3275ad24.png)
[paper reading | deep reading] anrl: attributed network representation learning via deep neural networks

Web3的先锋兵:虚拟人
随机推荐
Here comes a white paper to uncover the technology behind Clickhouse, a node with 10000 bytes!
慧通编程入门课程 - 2A闯关
1 -- Xintang nuc980 nuc980 porting uboot, starting from external mx25l
C#/VB.NET 删除Word文档中的水印
leetcode:5. Longest palindrome substring [DP + holding the tail of timeout]
Google Earth Engine(GEE)——Landsat 全球土地调查 1975年数据集
leetcode:5. 最长回文子串【dp + 抓着超时的尾巴】
你不可不知道的Selenium 8种元素定位方法,简单且实用
Apifox, is your API interface document rolled up like this?
go swagger使用
QPushButton-》函数精解
STM32 project -- Topic sharing (part)
fasterxml ToStringSerializerBase报错
数字滚动增加效果
Draco - glTF模型压缩利器
投资的再思考
Chang'an chain learning notes - certificate model of certificate research
[paper reading | deep reading] anrl: attributed network representation learning via deep neural networks
6-6漏洞利用-SSH安全防御
A new path for enterprise mid Platform Construction -- low code platform