@@ -6,6 +6,7 @@ import Hasher from './Hasher';
66import WorkerHelper from './WorkerHelper' ;
77import ConfigHelper from './ConfigHelper' ;
88import { formatMissingProjects , formatTimeDiff } from '../utils/functions' ;
9+ import Logger from '../utils/logger'
910
1011export default class BuildHelper extends WorkerHelper {
1112 projects = new Map ( ) ;
@@ -18,11 +19,9 @@ export default class BuildHelper extends WorkerHelper {
1819 super ( command ) ;
1920 }
2021
21- async init ( debug , compareWith , logLevel , logFunction ) {
22+ async init ( debug , compareWith ) {
2223 this . cacher = new Cacher ( ) . cacher ;
23- this . logLevel = logLevel ;
2424 this . startTime = process . hrtime ( ) ;
25- this . log = logFunction ( this . logLevel )
2625 if ( debug ) {
2726 this . debug = debug ;
2827 this . compareWith = compareWith ;
@@ -43,7 +42,7 @@ export default class BuildHelper extends WorkerHelper {
4342 } ) ;
4443 } catch ( error ) {
4544 if ( error . code === 'ENOENT' ) {
46- this . log ( 2 , 'Package.json file not found in the project!' ) ;
45+ Logger . log ( 2 , 'Package.json file not found in the project!' ) ;
4746 throw error ;
4847 } else {
4948 throw error ;
@@ -94,12 +93,12 @@ export default class BuildHelper extends WorkerHelper {
9493 if ( this . compareWith ) {
9594 const [ changedFiles , newFiles ] = Hasher . getUpdatedHashes ( ) ;
9695 if ( changedFiles . length || newFiles . length ) {
97- this . log ( 3 , `Hash mismatched: \n Changed files => \n - ${ changedFiles . join ( '\n' ) } \n New files => \n - ${ newFiles . join ( '\n' ) } ` ) ;
96+ Logger . log ( 3 , `Hash mismatched: \n Changed files => \n - ${ changedFiles . join ( '\n' ) } \n New files => \n - ${ newFiles . join ( '\n' ) } ` ) ;
9897 Hasher . emptyUpdatedHashes ( ) ;
9998 }
10099 }
101100 if ( ! isCached ) {
102- this . log ( 3 , 'Cache does not exist for => ' , buildProject , hash ) ;
101+ Logger . log ( 3 , 'Cache does not exist for => ' , buildProject , hash ) ;
103102
104103 const startTime = process . hrtime ( ) ;
105104 const output = await this . execute ( buildPath , script , hash , root , outputs ) ;
@@ -113,7 +112,7 @@ export default class BuildHelper extends WorkerHelper {
113112 if ( outputs . length ) {
114113 for ( const output of outputs ) {
115114 // const outputPath = path.join(ROOT_PATH, root, output);
116- this . log ( 3 , 'Recovering from cache' , buildProject , 'with hash => ' , hash ) ;
115+ Logger . log ( 3 , 'Recovering from cache' , buildProject , 'with hash => ' , hash ) ;
117116 const recoverResponse = await this . anotherJob ( hash , root , output ) ;
118117 if ( recoverResponse instanceof Error ) {
119118 throw new Error ( recoverResponse ) ;
@@ -138,7 +137,7 @@ export default class BuildHelper extends WorkerHelper {
138137 if ( ! projects . length ) {
139138 if ( ! stats . pendingTasks && ! stats . activeTasks ) {
140139 this . pool . terminate ( ) ;
141- this . log ( 2 , `
140+ Logger . log ( 2 , `
142141▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄ ▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄ ▄
143142▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░▌ ▐░░▌▐░░░░░░░░░░░▌▐░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░▌ ▐░▌
144143▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░▌░▌ ▐░▐░▌▐░█▀▀▀▀▀▀▀█░▌▐░▌ ▐░█▀▀▀▀▀▀▀▀▀ ▀▀▀▀█░█▀▀▀▀ ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░▌
@@ -151,14 +150,14 @@ export default class BuildHelper extends WorkerHelper {
151150▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌ ▐░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░▌ ▐░▌
152151 ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀ ▀
153152` ) ;
154- this . log ( 2 , `Total of ${ this . totalCount } project${ this . totalCount === 1 ? '' : 's' } has built.` ) ;
155- this . log ( 2 , `${ this . fromCache } project built from cache,` ) ;
156- this . log ( 2 , `${ this . built } project built without cache.` ) ;
157- this . log ( 2 , `Cache is missing for following projects => ${ formatMissingProjects ( this . missingProjects ) } ` ) ;
158- this . log ( 2 , `Total build took ${ formatTimeDiff ( process . hrtime ( this . startTime ) ) } .` ) ;
153+ Logger . log ( 2 , `Total of ${ this . totalCount } project${ this . totalCount === 1 ? '' : 's' } has built.` ) ;
154+ Logger . log ( 2 , `${ this . fromCache } project built from cache,` ) ;
155+ Logger . log ( 2 , `${ this . built } project built without cache.` ) ;
156+ Logger . log ( 2 , `Cache is missing for following projects => ${ formatMissingProjects ( this . missingProjects ) } ` ) ;
157+ Logger . log ( 2 , `Total build took ${ formatTimeDiff ( process . hrtime ( this . startTime ) ) } .` ) ;
159158 if ( this . debug && process . env . ZENITH_DEBUG_ID ) {
160159 this . cacher . updateDebugFile ( Hasher . getDebugJSON ( ) ) ;
161- this . log ( 2 , 'DEBUG JSON UPDATED' ) ;
160+ Logger . log ( 2 , 'DEBUG JSON UPDATED' ) ;
162161 }
163162 }
164163 return ;
0 commit comments