@@ -13,7 +13,7 @@ class Config {
1313 this . _cfg = fs . existsSync ( this . cfgPath ) ? JSON . parse ( fs . readFileSync ( this . cfgPath , "utf8" ) ) : { } ;
1414 const def = JSON . parse ( fs . readFileSync ( path . join ( process . cwd ( ) , "/defaultConfig.json" ) , "utf8" ) . trim ( ) ) ;
1515 const packageJson = JSON . parse ( fs . readFileSync ( path . join ( process . cwd ( ) , "/package.json" ) , "utf8" ) . trim ( ) ) ;
16- this . _cfg = extend ( true , { } , def , this . _cfg , { appVersion : { installed : packageJson . version } } ) ;
16+ this . _cfg = extend ( true , { } , def , this . _cfg , { appVersion : { installed : packageJson . version } } ) ;
1717 this . _isInitialized = true ;
1818 this . getEnvVariables ( ) ;
1919 this . update ( ) ;
@@ -46,7 +46,7 @@ class Config {
4646 }
4747 section = arr [ arr . length - 1 ] ;
4848 }
49- if ( JSON . stringify ( c [ section ] ) === JSON . stringify ( val ) ) {
49+ if ( JSON . stringify ( c [ section ] ) === JSON . stringify ( val ) ) {
5050 logger . silly ( `setSection: Config section and val are identical. Not updating.` )
5151 }
5252 else {
@@ -55,7 +55,7 @@ class Config {
5555 }
5656 }
5757
58- public getSection ( section ?: string , opts ?: any ) : any {
58+ public getSection ( section ?: string , opts ?: any ) : any {
5959 if ( typeof ( section ) === 'undefined' ) return this . _cfg ;
6060 var c : any = this . _cfg ;
6161 if ( section . indexOf ( '.' ) !== - 1 ) {
@@ -79,23 +79,20 @@ class Config {
7979 this . ensurePath ( baseDir + '/data/outQueues/' ) ;
8080 }
8181 private ensurePath ( dir : string ) {
82- if ( ! fs . existsSync ( dir ) ) {
83- fs . mkdir ( dir , ( err ) => {
84- // Logger will not be initialized by the time we reach here so we must
85- // simply log these to the console.
86- if ( err ) console . log ( `Error creating directory: ${ dir } - ${ err } ` ) ;
87- } ) ;
88- }
82+ fs . mkdir ( dir , { recursive : true } , ( err ) => {
83+ if ( err ) console . log ( `Error creating directory: ${ dir } - ${ err } ` ) ;
84+ } ) ;
8985 }
90- private getEnvVariables ( ) {
86+
87+ private getEnvVariables ( ) {
9188 // set docker env variables to config.json, if they are set
9289 let env = process . env ;
9390 if ( typeof env . POOL_HTTP_IP !== 'undefined' && env . POOL_HTTP_IP !== this . _cfg . web . services . ip ) {
9491 this . _cfg . web . services . ip = env . POOL_HTTP_IP ;
9592 }
96- if ( typeof env . POOL_HTTP_PORT !== 'undefined' && parseInt ( env . POOL_HTTP_PORT , 10 ) !== this . _cfg . web . services . port ) {
97- this . _cfg . web . services . port = parseInt ( env . POOL_HTTP_PORT , 10 ) ;
93+ if ( typeof env . POOL_HTTP_PORT !== 'undefined' && parseInt ( env . POOL_HTTP_PORT , 10 ) !== this . _cfg . web . services . port ) {
94+ this . _cfg . web . services . port = parseInt ( env . POOL_HTTP_PORT , 10 ) ;
9895 }
9996 }
10097}
101- export var config :Config = new Config ( ) ;
98+ export var config : Config = new Config ( ) ;
0 commit comments