import aliases from './config/aliases' ; import cliTruncate from 'cli-truncate' ; import chalk from 'chalk' ; export enum AliasesPosition { Left , Right } export default async function issueKeyExtended ( issueKey , aliasesPosition ) { const aliasNames = await aliases . getAliasNames ( issueKey ) ; const issueKeyText = chalk . bold ( issueKey ) ; if ( aliasNames . length === 0 ) return issueKeyText ; const aliasesText = chalk . gray ( getAliasesText ( aliasNames ) ) ; switch ( aliasesPosition ) { case AliasesPosition . Left : return `${ aliasesText } ${ issueKeyText }` ; case AliasesPosition . Right : return `${ issueKeyText } ${ aliasesText }` ; } } function getAliasesText ( aliasNames ) { const aliasesLength = aliasNames . length ; const firstAlias = aliasNames [ 0 ] ; let moreContent = '' ; if ( aliasesLength > 1 ) { moreContent = `, +${ aliasesLength - 1 }` ; } return `(${ cliTruncate ( firstAlias , 17 ) }${ moreContent })` ; }