GITLAB

WebSocket / websocketHO

Sign in
  • Sign in
  • Activity
  • Files
  • Commits
  • Network
  • Graphs
  • Issues 0
  • Merge Requests 0
  • Wiki
  • websocketho
  • watch
  • index.js
  • ba68e26e4   get entities and arts Browse Code ยป
    Eric Fernandez
    2019-05-30 10:11:55 -0300  
index.js 383 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 22
module.exports = function (dir, callback) {

  const fs = require('fs');
  const chokidar = require('chokidar');

  const watcher = chokidar.watch(dir);

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

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

    if (extencion == 'txt') {

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

        callback(fileString);
      });
    }

  });

};