1- const _ = require ( 'lodash' ) ;
2- const fs = require ( 'fs' ) ;
3- const logger = require ( '../logger' ) . nginx ;
4- const utils = require ( '../lib/utils ' ) ;
5- const error = require ( '../lib/error ' ) ;
6- const debug_mode = process . env . NODE_ENV !== 'production' || ! ! process . env . DEBUG ;
1+ const _ = require ( 'lodash' ) ;
2+ const fs = require ( 'fs' ) ;
3+ const logger = require ( '../logger' ) . nginx ;
4+ const config = require ( '../lib/config ' ) ;
5+ const utils = require ( '../lib/utils ' ) ;
6+ const error = require ( '../lib/error' ) ;
77
88const internalNginx = {
99
@@ -65,7 +65,7 @@ const internalNginx = {
6565 }
6666 } ) ;
6767
68- if ( debug_mode ) {
68+ if ( config . debug ( ) ) {
6969 logger . error ( 'Nginx test failed:' , valid_lines . join ( '\n' ) ) ;
7070 }
7171
@@ -101,7 +101,7 @@ const internalNginx = {
101101 * @returns {Promise }
102102 */
103103 test : ( ) => {
104- if ( debug_mode ) {
104+ if ( config . debug ( ) ) {
105105 logger . info ( 'Testing Nginx configuration' ) ;
106106 }
107107
@@ -184,7 +184,7 @@ const internalNginx = {
184184 generateConfig : ( host_type , host ) => {
185185 const nice_host_type = internalNginx . getFileFriendlyHostType ( host_type ) ;
186186
187- if ( debug_mode ) {
187+ if ( config . debug ( ) ) {
188188 logger . info ( 'Generating ' + nice_host_type + ' Config:' , JSON . stringify ( host , null , 2 ) ) ;
189189 }
190190
@@ -239,7 +239,7 @@ const internalNginx = {
239239 . then ( ( config_text ) => {
240240 fs . writeFileSync ( filename , config_text , { encoding : 'utf8' } ) ;
241241
242- if ( debug_mode ) {
242+ if ( config . debug ( ) ) {
243243 logger . success ( 'Wrote config:' , filename , config_text ) ;
244244 }
245245
@@ -249,7 +249,7 @@ const internalNginx = {
249249 resolve ( true ) ;
250250 } )
251251 . catch ( ( err ) => {
252- if ( debug_mode ) {
252+ if ( config . debug ( ) ) {
253253 logger . warn ( 'Could not write ' + filename + ':' , err . message ) ;
254254 }
255255
@@ -268,7 +268,7 @@ const internalNginx = {
268268 * @returns {Promise }
269269 */
270270 generateLetsEncryptRequestConfig : ( certificate ) => {
271- if ( debug_mode ) {
271+ if ( config . debug ( ) ) {
272272 logger . info ( 'Generating LetsEncrypt Request Config:' , certificate ) ;
273273 }
274274
@@ -292,14 +292,14 @@ const internalNginx = {
292292 . then ( ( config_text ) => {
293293 fs . writeFileSync ( filename , config_text , { encoding : 'utf8' } ) ;
294294
295- if ( debug_mode ) {
295+ if ( config . debug ( ) ) {
296296 logger . success ( 'Wrote config:' , filename , config_text ) ;
297297 }
298298
299299 resolve ( true ) ;
300300 } )
301301 . catch ( ( err ) => {
302- if ( debug_mode ) {
302+ if ( config . debug ( ) ) {
303303 logger . warn ( 'Could not write ' + filename + ':' , err . message ) ;
304304 }
305305
@@ -416,8 +416,8 @@ const internalNginx = {
416416 * @param {string } config
417417 * @returns {boolean }
418418 */
419- advancedConfigHasDefaultLocation : function ( config ) {
420- return ! ! config . match ( / ^ (?: .* ; ) ? \s * ?l o c a t i o n \s * ?\/ \s * ?{ / im) ;
419+ advancedConfigHasDefaultLocation : function ( cfg ) {
420+ return ! ! cfg . match ( / ^ (?: .* ; ) ? \s * ?l o c a t i o n \s * ?\/ \s * ?{ / im) ;
421421 } ,
422422
423423 /**
0 commit comments