Commit c92ddeb7de61a28ee66a4d4857b19f05d7c86d73

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'master'

Master(efernandez)

See merge request !19
1 module.exports = function (dir, callback) { 1 module.exports = function (dir, callback) {
2 2
3 const chokidar = require('chokidar'); 3 const chokidar = require('chokidar');
4 4
5 const watcher = chokidar.watch(dir, { ignored: [config.dirDestino, config.dirRecadv] }); 5 const watcher = chokidar.watch(dir, { ignored: [config.dirDestino, config.dirRecadv] });
6 6
7 watcher.on('add', function(file) { 7 watcher.on('add', function(file) {
8 8
9 var extencion = file.split('.')[1]; 9 var extencion = file.split('.')[1];
10 10
11 if (extencion == 'txt') { 11 if (extencion == 'txt') {
12 12
13 fs.readFile(file, 'utf8', function (err, fileString) { 13 fs.readFile(file, 'utf8', function (err, fileString) {
14 14
15 if (err) { 15 if (err) {
16 console.log('ERROR', err); 16 console.log('ERROR', err);
17 return; 17 return;
18 } 18 }
19 19
20 console.log(`iniciando proceso ${file}`);
20 callback(fileString, file); 21 callback(fileString, file);
21 }); 22 });
22 } 23 }
23 24
24 }); 25 });
25 26
26 }; 27 };
27 28