Skip to content

Commit

Permalink
Extract truncation function
Browse files Browse the repository at this point in the history
  • Loading branch information
rcrichton committed Apr 19, 2024
1 parent 975dd1b commit d3b714c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions instant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ export const concurrentifyAction = (
}
}

const truncateString = (str: string, maxLength: number) => {
return str.length > maxLength
? `${str.substring(0, maxLength - 10)}...[trunc]`
: str
}

const setEnvVars = (packageInfo: PackageInfo) => {
const envVars = [] as EnvironmentVar[]

Expand All @@ -202,14 +208,8 @@ const setEnvVars = (packageInfo: PackageInfo) => {
console.table(
envVars.map(
({ 'Environment Variable': envVar, 'Current Value': currVal }) => ({
'Environment Variable':
envVar.length > 50
? `${envVar.substring(0, 50)}...[trunc]`
: envVar,
'Current Value':
currVal && currVal.length > 50
? `${currVal.substring(0, 50)}...[trunc]`
: currVal
'Environment Variable': truncateString(envVar, 50),
'Current Value': truncateString(currVal || '', 50)
})
)
)
Expand Down

0 comments on commit d3b714c

Please sign in to comment.