文件管理器,用于nodejs文件夹中的文件

时间:2017-08-10 15:12:35

标签: node.js filesystems

我的用例是使用NodeJS观察文件系统(unix)上的文件添加,添加是因为复制文件夹包含“watched”文件夹中的文件, 问题我只为添加的目录而不是内部文件获取事件。我试图使用几个监视库“watchr”和“node-watch”,但两者的行为相同。

例如我看“to_watch”文件夹并在那里复制“temp”文件夹包含随机命名文件,我只为“temp”获得了事件

  

在to_watch上观看成功

     

文件to_watch / temp已创建..

1 个答案:

答案 0 :(得分:0)

在尝试了几个库后,我发现了一个符合我要求的库,“chokidar”

  

npm install chokidar --save

var chokidar = require('chokidar');

// One-liner for current directory, ignores .dotfiles
chokidar.watch('.', {ignored: /(^|[\/\\])\../}).on('all', (event, path) => {
  console.log(event, path);
});