@@ -68,11 +68,11 @@ function requestListener(req, res) {
6868        if  ( ! err  &&  stats . isFile ( ) )  { 
6969            fileBuffer  =  fs . readFileSync ( possibleFilename ) ; 
7070            let  ct  =  mime . lookup ( possibleFilename ) ; 
71-             console . log ( `Sending ${ possibleFilename }   with Content-Type ${ ct }  ` ) ; 
71+             log ( `Sending ${ possibleFilename }   with Content-Type ${ ct }  ` ) ; 
7272            res . writeHead ( 200 ,  {  'Content-Type' : ct  } ) ; 
7373
7474        }  else  { 
75-             console . log ( "Route %s, replacing with index.html" ,  possibleFilename ) ; 
75+             log ( "Route %s, replacing with index.html" ,  possibleFilename ) ; 
7676            fileBuffer  =  returnDistFile ( ) ; 
7777            res . writeHead ( 200 ,  {  'Content-Type' : 'text/html'  } ) ; 
7878        } 
@@ -102,26 +102,26 @@ function returnDistFile(displayFileMessages = false) {
102102    if  ( argvPath )  { 
103103        try  { 
104104          if  ( displayFileMessages )  { 
105-             console . log ( "Path specified: %s" ,  argvPath ) ; 
105+             log ( "Path specified: %s" ,  argvPath ) ; 
106106          } 
107107          distPath  =  path . join ( argvPath ,  'index.html' ) ; 
108108          if  ( displayFileMessages )  { 
109-             console . log ( "Using %s" ,  distPath ) ; 
109+             log ( "Using %s" ,  distPath ) ; 
110110          } 
111111          return  fs . readFileSync ( distPath ) ; 
112112        }  catch  ( e )  { 
113-           console . log ( NO_PATH_FILE_ERROR_MESSAGE  +  "%s" ,  argvPath ) ; 
113+           console . warn ( NO_PATH_FILE_ERROR_MESSAGE  +  "%s" ,  argvPath ) ; 
114114          process . exit ( 1 ) ; 
115115        } 
116116    }  else  { 
117117        if  ( displayFileMessages )  { 
118-           console . log ( "Info: Path not specified using the working directory." ) ; 
118+           log ( "Info: Path not specified using the working directory." ) ; 
119119        } 
120120        distPath  =  "index.html" ; 
121121        try  { 
122122          return  fs . readFileSync ( distPath ) ; 
123123        }  catch  ( e )  { 
124-           console . log ( NO_ROOT_FILE_ERROR_MESSAGE ) ; 
124+           console . warn ( NO_ROOT_FILE_ERROR_MESSAGE ) ; 
125125          process . exit ( 1 ) ; 
126126        } 
127127    } 
@@ -138,3 +138,9 @@ function resolveUrl(filename) {
138138        return  filename ; 
139139    } 
140140} 
141+ 
142+ function  log ( )  { 
143+     if  ( ! argv . silent )  { 
144+         console . log . apply ( console ,  arguments ) ; 
145+     } 
146+ } 
0 commit comments