🎨 App > Watcher > Handle file errors

This commit is contained in:
brunosimon
2018-01-09 23:10:03 +01:00
parent eea1a6687e
commit 0eb32694e4
+28
View File
@@ -151,6 +151,13 @@ class Watcher
// Retrieve stats // Retrieve stats
fs.stat(_path, (error, stats) => fs.stat(_path, (error, stats) =>
{ {
// Error
if(error)
{
console.log(`${chalk.green.bold('watcher')} - ${chalk.cyan('add')} - ${chalk.cyan(_path)} - ${chalk.red('error')}`)
return
}
// Max file size // Max file size
if(this.config.maxFileSize < stats.size) if(this.config.maxFileSize < stats.size)
{ {
@@ -160,6 +167,13 @@ class Watcher
// Read // Read
fs.readFile(_path, (error, data) => fs.readFile(_path, (error, data) =>
{ {
// Error
if(error)
{
console.log(`${chalk.green.bold('watcher')} - ${chalk.cyan('add')} - ${chalk.cyan(_path)} - ${chalk.red('error')}`)
return
}
if(file.canRead) if(file.canRead)
{ {
file.content = data.toString() file.content = data.toString()
@@ -197,6 +211,13 @@ class Watcher
// Retrieve stats // Retrieve stats
fs.stat(_path, (error, stats) => fs.stat(_path, (error, stats) =>
{ {
// Error
if(error)
{
console.log(`${chalk.green.bold('watcher')} - ${chalk.cyan('change')} - ${chalk.cyan(_path)} - ${chalk.red('error')}`)
return
}
// Test max file size // Test max file size
if(this.config.maxFileSize < stats.size) if(this.config.maxFileSize < stats.size)
{ {
@@ -206,6 +227,13 @@ class Watcher
// Read // Read
fs.readFile(_path, (error, data) => fs.readFile(_path, (error, data) =>
{ {
// Error
if(error)
{
console.log(`${chalk.green.bold('watcher')} - ${chalk.cyan('change')} - ${chalk.cyan(_path)} - ${chalk.red('error')}`)
return
}
if(file.canRead) if(file.canRead)
{ {
file.content = data.toString() file.content = data.toString()