import moment = require ( 'moment' ) ; import { LoggingLevel } from '../enums' ; import * as sharedModels from '../models' ; export class Utils { static isIgnored ( value ) { if ( ! value ) { return true ; } return value . toLowerCase ( ) === 'ignore' ; } static transformDates ( value , regExModel ) { return value . replace ( regExModel . date , ( match , g1 , g2 ) : string => { return moment ( ) . format ( g1 ) ; } ) ; } static setWildcardVersionNumber ( value , verBuild , verRelease ) { if ( ! value || value === '' ) { return value ; } if ( value . includes ( '.*.*' ) ) { value = value . replace ( '.*.*' , `.${ verBuild }.${ verRelease }` ) ; } else if ( value . includes ( '.*' ) ) { value = value . replace ( '.*' , `.${ verBuild }` ) ; } return value ; } static setVersionNumber ( existingVersion , newVersion ) { if ( ! existingVersion || existingVersion === '' || ! newVersion . includes ( '#' ) ) { return newVersion ; } let existingVersionArray = existingVersion . split ( '.' ) ; let newVersionArray = newVersion . split ( '.' ) ; newVersionArray . forEach ( ( value , index , array ) => { if ( ! value . startsWith ( '#' ) ) { existingVersionArray [ index ] = value ; } } ) ; return existingVersionArray . join ( '.' ) ; } static formatFileNames ( fileNames ) { const targetFiles = [ ] ; fileNames . forEach ( ( x ) => { if ( x ) { x . split ( ',' ) . forEach ( ( y ) => { if ( y ) { targetFiles . push ( y . trim ( ) ) ; } } ) ; } } ) ; return targetFiles ; } static mapLogLevel ( level ) { switch ( level ) { case 'normal' : return LoggingLevel . Normal ; case 'verbose' : return LoggingLevel . Verbose ; case 'off' : return LoggingLevel . Off ; } return LoggingLevel . Normal ; } }