当前位置:网站首页>[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 !
边栏推荐
- [paper reading | deep reading] graphsage:inductive representation learning on large graphs
- [unity] upgraded version · Excel data analysis, automatically create corresponding C classes, automatically create scriptableobject generation classes, and automatically serialize asset files
- 你不可不知道的Selenium 8种元素定位方法,简单且实用
- unity 自定义webgl打包模板
- QPushButton-》函数精解
- B站6月榜单丨飞瓜数据UP主成长排行榜(哔哩哔哩平台)发布!
- MySQL
- 一本揭秘字节万台节点ClickHouse背后技术实现的白皮书来了!
- 纽约大学 CITIES 研究中心招聘理学硕士和博士后
- 【Node学习笔记】chokidar模块实现文件监听
猜你喜欢
Stm32f4 --- PWM output
Station B's June ranking list - feigua data up main growth ranking list (BiliBili platform) is released!
Draco - gltf model compression tool
进程管理基础
MySQL --- 常用函数 - 字符串函数
6-6漏洞利用-SSH安全防御
The third season of ape table school is about to launch, opening a new vision for developers under the wave of going to sea
一文读懂Faster RCNN
人脸识别应用解析
fiddler的使用
随机推荐
一文读懂Faster RCNN
leetcode:736. LISP syntax parsing [flowery + stack + status enumaotu + slots]
MMDetection3D加载毫米波雷达数据
postgresql 之 数据目录内部结构 简介
1 -- Xintang nuc980 nuc980 porting uboot, starting from external mx25l
Summer Challenge database Xueba notes (Part 2)~
记一次JAP查询导致OOM的问题分析
unity中跟随鼠标浮动的面板,并可以自适应文字内容的大小
Here comes a white paper to uncover the technology behind Clickhouse, a node with 10000 bytes!
C#/VB. Net to delete watermarks in word documents
数字滚动增加效果
Web3's need for law
New generation cloud native message queue (I)
Ali yunyili: how does yunyuansheng solve the problem of reducing costs and improving efficiency?
Web3对法律的需求
阿里云易立:云原生如何破解企业降本提效难题?
Web3的先锋兵:虚拟人
Yyds dry goods inventory # solve the real problem of famous enterprises: maximum difference
Common fitting models and application methods of PCL
Why am I warned that the 'CMAKE_ TOOLCHAIN_ FILE' variable is not used by the project?