🎨 App > Watcher > Handle file errors
This commit is contained in:
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user