Skip to content

Commit 3ca0978

Browse files
authored
fix: extract inline constants for better readability and consistency (#18)
1 parent 2683ed6 commit 3ca0978

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/commands/types/index.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@ export async function handler(_argv: ReturnType<typeof builder>['argv']): Promis
3636

3737
for (const publishes of eitherHandler.right.publishes ?? []) {
3838
if ('eventbridge' in publishes) {
39-
constants[camelcase(`eventbridge_${publishes.eventbridge.eventBusId}`)] =
40-
`STARCHART_EVENTBRIDGE_${publishes.eventbridge.eventBusId.replace(/[^a-zA-Z0-9]+/g, '_').toUpperCase()}`
39+
const _eventBusId = publishes.eventbridge.eventBusId.replace(/[^a-zA-Z0-9]+/g, '_')
40+
constants[camelcase(`eventbridge_${_eventBusId}`)] = `STARCHART_EVENTBRIDGE_${_eventBusId.toUpperCase()}`
4141
} else if ('sqs' in publishes) {
42-
constants[camelcase(`sqs_${publishes.sqs.queueId}`)] =
43-
`STARCHART_SQS_${publishes.sqs.queueId.replace(/[^a-zA-Z0-9]+/g, '_').toUpperCase()}_QUEUE_URL`
42+
const _queueId = publishes.sqs.queueId.replace(/[^a-zA-Z0-9]+/g, '_')
43+
constants[camelcase(`sqs_${_queueId}`)] = `STARCHART_SQS_${_queueId.toUpperCase()}_QUEUE_URL`
4444
}
4545
}
4646

4747
for (const resource of eitherHandler.right.resources ?? []) {
4848
if ('dynamodb' in resource) {
49-
constants[camelcase(`dynamodb_${resource.dynamodb.tableId}`)] =
50-
`STARCHART_${resource.dynamodb.tableId.replace(/[^a-zA-Z0-9]+/g, '_').toUpperCase()}_TABLE_NAME`
49+
const _tableId = resource.dynamodb.tableId.replace(/[^a-zA-Z0-9]+/g, '_')
50+
constants[camelcase(`dynamodb_${_tableId}`)] = `STARCHART_${_tableId.toUpperCase()}_TABLE_NAME`
5151
} else if ('s3' in resource) {
52-
constants[camelcase(`s3_${resource.s3.bucketId}`)] =
53-
`STARCHART_${resource.s3.bucketId.replace(/[^a-zA-Z0-9]+/g, '_').toUpperCase()}_BUCKET_NAME`
52+
const _bucketId = resource.s3.bucketId.replace(/[^a-zA-Z0-9]+/g, '_')
53+
constants[camelcase(`s3_${_bucketId}`)] = `STARCHART_${_bucketId.toUpperCase()}_BUCKET_NAME`
5454
}
5555

5656
// @todo add secrets and parameters

0 commit comments

Comments
 (0)