✨ Add path exclusion
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
{
|
||||
"debug" : false,
|
||||
"port" : 1571,
|
||||
"max_file_size" : 2000
|
||||
"debug" : false,
|
||||
"port" : 1571,
|
||||
"max_file_size": 99999,
|
||||
"exclude" :
|
||||
[
|
||||
"node_modules/**",
|
||||
"vendors/**"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -55,6 +55,9 @@ class Keppler
|
||||
if( typeof _options.max_file_size === 'undefined' )
|
||||
_options.max_file_size = default_config.max_file_size
|
||||
|
||||
if( typeof _options.exclude === 'undefined' )
|
||||
_options.exclude = default_config.exclude
|
||||
|
||||
// Save
|
||||
this.options = _options
|
||||
}
|
||||
@@ -101,6 +104,7 @@ class Keppler
|
||||
domain : this.options.domain,
|
||||
debug : this.options.debug,
|
||||
max_file_size: this.options.max_file_size,
|
||||
exclude : this.options.exclude,
|
||||
name : this.arguments[ 0 ]
|
||||
} )
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"helmet": "^2.1.0",
|
||||
"ip": "^1.1.3",
|
||||
"mime": "^1.3.4",
|
||||
"minimatch": "^3.0.3",
|
||||
"pug": "^2.0.0-beta4",
|
||||
"slug": "^0.9.1",
|
||||
"socket.io": "^1.4.6",
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
This file shouldn't be include
|
||||
@@ -7,7 +7,8 @@ let chokidar = require( 'chokidar' ),
|
||||
ip = require( 'ip' ),
|
||||
socket_io_client = require( 'socket.io-client' ),
|
||||
fs = require( 'fs' ),
|
||||
mime = require( 'mime' )
|
||||
mime = require( 'mime' ),
|
||||
minimatch = require( 'minimatch' )
|
||||
|
||||
/**
|
||||
* Watcher class
|
||||
@@ -104,9 +105,22 @@ class Watcher
|
||||
file.can_read = false;
|
||||
}
|
||||
|
||||
// Test exclusion
|
||||
for( let _exclude_key in this.options.exclude )
|
||||
{
|
||||
// Set up
|
||||
let _exclude = this.options.exclude[ _exclude_key ],
|
||||
relative_path = _path.replace( process.cwd() + '/', '' )
|
||||
|
||||
// Match excluded path
|
||||
if( minimatch( relative_path, _exclude ) )
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve stats
|
||||
fs.stat( _path, ( error, stats ) =>
|
||||
{
|
||||
// Max file size
|
||||
if( stats.size > this.options.max_file_size )
|
||||
file.can_read = false
|
||||
|
||||
@@ -145,9 +159,22 @@ class Watcher
|
||||
file.can_read = false;
|
||||
}
|
||||
|
||||
// Test exclusion
|
||||
for( let _exclude_key in this.options.exclude )
|
||||
{
|
||||
// Set up
|
||||
let _exclude = this.options.exclude[ _exclude_key ],
|
||||
relative_path = _path.replace( process.cwd() + '/', '' )
|
||||
|
||||
// Match excluded path
|
||||
if( minimatch( relative_path, _exclude ) )
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve stats
|
||||
fs.stat( _path, ( error, stats ) =>
|
||||
{
|
||||
// Test max file size
|
||||
if( stats.size > this.options.max_file_size )
|
||||
file.can_read = false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user