Skip to content

Commit f70ed70

Browse files
chore: Fix PR comments
This fixes PR comments: - Dont use underscore for private - Refactor variables to make accepted sequences more clear Signed-off-by: Nikolas Komonen <[email protected]>
1 parent db4c1d0 commit f70ed70

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/shared/sam/cli/samCliInvokerUtils.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,36 @@ export function logAndThrowIfUnexpectedExitCode(processResult: ChildProcessResul
6666
*/
6767
export function collectAcceptedErrorMessages(errorMessage: string): string[] {
6868
const errors = errorMessage.split('\n')
69-
const shouldCollectFuncs = [_startsWithEscapeSequence, _startsWithError]
69+
const shouldCollectFuncs = [startsWithEscapeSequence, startsWithError]
7070
return errors.filter(error => {
7171
return shouldCollectFuncs.some(shouldCollect => {
7272
return shouldCollect(error)
7373
})
7474
})
7575
}
7676

77+
/**
78+
* All accepted escape sequences.
79+
*/
80+
const yellowForeground = '[33m'
81+
const acceptedSequences = [yellowForeground]
82+
7783
/**
7884
* Returns true if text starts with an escape
7985
* sequence with one of the accepted sequences.
8086
*/
81-
function _startsWithEscapeSequence(text: string): boolean {
87+
function startsWithEscapeSequence(text: string, sequences = acceptedSequences): boolean {
8288
const escapeInDecimal = 27
8389
if (text.charCodeAt(0) !== escapeInDecimal) {
8490
return false
8591
}
8692

8793
const remainingText = text.substring(1)
88-
const acceptedSequences = ['[33m']
89-
return acceptedSequences.some(code => {
94+
return sequences.some(code => {
9095
return remainingText.startsWith(code)
9196
})
9297
}
9398

94-
function _startsWithError(text: string): boolean {
99+
function startsWithError(text: string): boolean {
95100
return text.startsWith('Error:')
96101
}

0 commit comments

Comments
 (0)