Commit cafb195b5c864a0f25ef74fd9f5a53afe6aff9c3

Authored by Eric Fernandez
1 parent f5a4882603
Exists in master

catch err on readFile

Showing 1 changed file with 5 additions and 0 deletions   Show diff stats
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 }); 5 const watcher = chokidar.watch(dir, { ignored: config.dirDestino });
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) {
16 console.log('ERROR', err);
17 return;
18 }
19
15 callback(fileString, file); 20 callback(fileString, file);
16 }); 21 });
17 } 22 }
18 23
19 }); 24 });
20 25
21 }; 26 };
22 27