22const webpack = require ( 'webpack' ) ;
33const chalk = require ( 'chalk' ) ;
44const Table = require ( 'cli-table3' ) ;
5+ const logger = require ( './logger' ) ;
56
67function setUpHookForCompiler ( compiler , outputOptions , options ) {
78 const { ProgressPlugin } = webpack ;
@@ -20,7 +21,7 @@ function setUpHookForCompiler(compiler, outputOptions, options) {
2021 }
2122
2223 if ( msg && tmpMsg != msg ) {
23- process . cliLogger . info ( percent + '% ' + msg ) ;
24+ logger . info ( percent + '% ' + msg ) ;
2425 }
2526 tmpMsg = msg ;
2627 } ;
@@ -44,17 +45,17 @@ function setUpHookForCompiler(compiler, outputOptions, options) {
4445 if ( outputOptions . watch ) {
4546 compiler . hooks . watchRun . tap ( 'WebpackInfo' , compilation => {
4647 const compilationName = compilation . name ? compilation . name : '' ;
47- process . cliLogger . info ( 'Compilation ' + compilationName + ' starting…' ) ;
48+ logger . info ( 'Compilation ' + compilationName + ' starting…' ) ;
4849 } ) ;
4950 } else {
5051 compiler . hooks . beforeRun . tap ( 'WebpackInfo' , compilation => {
5152 const compilationName = compilation . name ? compilation . name : '' ;
52- process . cliLogger . info ( 'Compilation ' + compilationName + ' starting…' ) ;
53+ logger . info ( 'Compilation ' + compilationName + ' starting…' ) ;
5354 } ) ;
5455 }
5556 compiler . hooks . done . tap ( 'WebpackInfo' , compilation => {
5657 const compilationName = compilation . name ? compilation . name : '' ;
57- process . cliLogger . info ( 'Compilation ' + compilationName + ' finished' ) ;
58+ logger . info ( 'Compilation ' + compilationName + ' finished' ) ;
5859 } ) ;
5960 }
6061}
@@ -117,22 +118,22 @@ function generateOutputForSingleCompilation(statsObj, statsErrors, processingMes
117118 process . stdout . write ( '\n\n' ) ;
118119
119120 if ( warning . message ) {
120- process . cliLogger . warn ( warning . message ) ;
121+ logger . warn ( warning . message ) ;
121122 process . stdout . write ( '\n' ) ;
122- process . cliLogger . warn ( warning . stack ) ;
123+ logger . warn ( warning . stack ) ;
123124 return ;
124125 }
125- process . cliLogger . warn ( warning ) ;
126+ logger . warn ( warning ) ;
126127 } ) ;
127128 process . stdout . write ( '\n' ) ;
128129 }
129130
130131 if ( statsErrors ) {
131132 statsErrors . forEach ( err => {
132- if ( err . loc ) process . cliLogger . warn ( err . loc ) ;
133+ if ( err . loc ) logger . warn ( err . loc ) ;
133134 if ( err . name ) {
134135 process . stdout . write ( '\n' ) ;
135- process . cliLogger . error ( err . name ) ;
136+ logger . error ( err . name ) ;
136137 }
137138 } ) ;
138139 }
@@ -150,7 +151,7 @@ function generateOutput(outputOptions, stats, statsErrors, processingMessageBuff
150151 generateOutputForSingleCompilation ( statsObj , statsErrors , processingMessageBuffer ) ;
151152 process . stdout . write ( '\n' ) ;
152153 if ( outputOptions . watch ) {
153- process . cliLogger . info ( 'watching files for updates...' ) ;
154+ logger . info ( 'watching files for updates...' ) ;
154155 }
155156}
156157
@@ -163,7 +164,7 @@ function compilerCallback(compiler, err, stats, lastHash, options, outputOptions
163164 }
164165 if ( err ) {
165166 lastHash = null ;
166- process . cliLogger . error ( err . stack || err ) ;
167+ logger . error ( err . stack || err ) ;
167168 process . exit ( 1 ) ; // eslint-disable-line
168169 }
169170 if ( outputOptions . json && ! outputOptions . silent ) {
@@ -213,7 +214,7 @@ async function webpackInstance(opts) {
213214 compiler = getCompiler ( options ) ;
214215 } catch ( err ) {
215216 process . stdout . write ( '\n' ) ;
216- process . cliLogger . error ( `${ err . name } : ${ err . message } ` ) ;
217+ logger . error ( `${ err . name } : ${ err . message } ` ) ;
217218 process . stdout . write ( '\n' ) ;
218219 return ;
219220 }
0 commit comments