GITLAB

WebSocket / websocketHO

Sign in
  • Sign in
  • Activity
  • Files
  • Commits
  • Network
  • Graphs
  • Issues 0
  • Merge Requests 0
  • Wiki
  • websocketho
  • watch
  • index.js
  • f5a488260   delete pmae pmov temp Browse Code ยป
    Eric Fernandez
    2019-06-19 16:55:03 -0300  
index.js 393 Bytes
edit raw blame history
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
module.exports = function (dir, callback) {

  const chokidar = require('chokidar');

  const watcher = chokidar.watch(dir, { ignored: config.dirDestino });

  watcher.on('add', function(file) {

    var extencion = file.split('.')[1];

    if (extencion == 'txt') {

      fs.readFile(file, 'utf8', function (err, fileString) {

        callback(fileString, file);
      });
    }

  });

};