✨ Default config file
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"debug" : false,
|
||||||
|
"port" : 1571,
|
||||||
|
"max_file_size" : 2000
|
||||||
|
}
|
||||||
@@ -5,7 +5,8 @@ let path = require( 'path' ),
|
|||||||
colors = require( 'colors' ),
|
colors = require( 'colors' ),
|
||||||
ip = require( 'ip' ),
|
ip = require( 'ip' ),
|
||||||
Site = require( '../site/site.class.js' ),
|
Site = require( '../site/site.class.js' ),
|
||||||
Watcher = require( '../watcher/watcher.class.js' )
|
Watcher = require( '../watcher/watcher.class.js' ),
|
||||||
|
default_config = require( './config.default.json' )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keppler class
|
* Keppler class
|
||||||
@@ -35,22 +36,25 @@ class Keppler
|
|||||||
// Defaults
|
// Defaults
|
||||||
if( typeof _options.debug === 'undefined' )
|
if( typeof _options.debug === 'undefined' )
|
||||||
{
|
{
|
||||||
if( this.arguments.length )
|
if( this.arguments.length > 1 )
|
||||||
{
|
{
|
||||||
_options.debug = this.arguments[ this.arguments.length - 1 ] === 'true' ? true : false
|
_options.debug = this.arguments[ this.arguments.length - 1 ] === 'true' ? true : false
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_options.debug = false
|
_options.debug = default_config.debug
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( typeof _options.port === 'undefined' )
|
if( typeof _options.port === 'undefined' )
|
||||||
_options.port = 1571
|
_options.port = default_config.port
|
||||||
|
|
||||||
if( typeof _options.domain === 'undefined' )
|
if( typeof _options.domain === 'undefined' )
|
||||||
_options.domain = `http://${ip.address()}:${_options.port}`
|
_options.domain = `http://${ip.address()}:${_options.port}`
|
||||||
|
|
||||||
|
if( typeof _options.max_file_size === 'undefined' )
|
||||||
|
_options.max_file_size = default_config.max_file_size
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
this.options = _options
|
this.options = _options
|
||||||
}
|
}
|
||||||
@@ -96,6 +100,7 @@ class Keppler
|
|||||||
port : this.options.port,
|
port : this.options.port,
|
||||||
domain : this.options.domain,
|
domain : this.options.domain,
|
||||||
debug : this.options.debug,
|
debug : this.options.debug,
|
||||||
|
max_file_size: this.options.max_file_size,
|
||||||
name : this.arguments[ 0 ]
|
name : this.arguments[ 0 ]
|
||||||
} )
|
} )
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ class Watcher
|
|||||||
if( typeof _options.domain === 'undefined' )
|
if( typeof _options.domain === 'undefined' )
|
||||||
_options.domain = `http://${ip.address()}:${_options.port}`
|
_options.domain = `http://${ip.address()}:${_options.port}`
|
||||||
|
|
||||||
|
if( typeof _options.max_file_size === 'undefined' )
|
||||||
|
_options.max_file_size = 2000
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
this.options = _options
|
this.options = _options
|
||||||
}
|
}
|
||||||
@@ -104,7 +107,7 @@ class Watcher
|
|||||||
// Retrieve stats
|
// Retrieve stats
|
||||||
fs.stat( _path, ( error, stats ) =>
|
fs.stat( _path, ( error, stats ) =>
|
||||||
{
|
{
|
||||||
if( stats.size > 999999 )
|
if( stats.size > this.options.max_file_size )
|
||||||
file.can_read = false
|
file.can_read = false
|
||||||
|
|
||||||
// Read
|
// Read
|
||||||
@@ -145,7 +148,7 @@ class Watcher
|
|||||||
// Retrieve stats
|
// Retrieve stats
|
||||||
fs.stat( _path, ( error, stats ) =>
|
fs.stat( _path, ( error, stats ) =>
|
||||||
{
|
{
|
||||||
if( stats.size > 999999 )
|
if( stats.size > this.options.max_file_size )
|
||||||
file.can_read = false
|
file.can_read = false
|
||||||
|
|
||||||
// Read
|
// Read
|
||||||
|
|||||||
Reference in New Issue
Block a user