当前位置:网站首页>[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 !
边栏推荐
- leetcode:5. 最长回文子串【dp + 抓着超时的尾巴】
- 所谓的消费互联网仅仅只是做行业信息的撮合和对接,并不改变产业本身
- Go swagger use
- 安德鲁斯—-多媒体编程
- Web3's need for law
- Gee upgrade can realize one piece of run tasks
- Here comes a white paper to uncover the technology behind Clickhouse, a node with 10000 bytes!
- MES管理系统的应用和好处有哪些
- GEE升级,可以实现一件run tasks
- Lidar: introduction and usage of ouster OS
猜你喜欢
unity中跟随鼠标浮动的面板,并可以自适应文字内容的大小
【森城市】GIS数据漫谈(二)
Recommended collection!! Which is the best flutter status management plug-in? Please look at the ranking list of yard farmers on the island!
1个月增长900w+播放!总结B站顶流恰饭的2个新趋势
Overall query process of PostgreSQL
postgresql之integerset
MATLB|具有储能的经济调度及机会约束和鲁棒优化
leetcode:5. Longest palindrome substring [DP + holding the tail of timeout]
Google Earth Engine(GEE)——Landsat 全球土地调查 1975年数据集
Lidar: introduction and usage of ouster OS
随机推荐
Stm32f4 --- PWM output
A new path for enterprise mid Platform Construction -- low code platform
投资的再思考
数论 --- 快速幂、快速幂求逆元
Web3对法律的需求
所谓的消费互联网仅仅只是做行业信息的撮合和对接,并不改变产业本身
普通测试年薪15w,测试开发年薪30w+,二者差距在哪?
Introduction to the internal structure of the data directory of PostgreSQL
STM32 project -- Topic sharing (part)
导数、偏导数、方向导数
3 -- Xintang nuc980 kernel supports JFFS2, JFFS2 file system production, kernel mount JFFS2, uboot network port settings, and uboot supports TFTP
Use of fiddler
Introduction to FLIR blackfly s industrial camera
Detailed explanation of line segment tree (including tested code implementation)
Fundamentals of process management
Lumion 11.0 software installation package download and installation tutorial
MySQL --- 常用函数 - 字符串函数
软件测试——Jmeter接口测试之常用断言
Douban average 9 x. Five God books in the distributed field!
Halcon instance to opencvsharp (C openCV) implementation -- bottle mouth defect detection (with source code)