Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
e251dac4
Unverified
Commit
e251dac4
authored
Mar 14, 2023
by
mergify[bot]
Committed by
GitHub
Mar 14, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5126 from ethereum-optimism/inphi/fix-svc
fix(cmn): BaseServiceV2 throws on camelCase options
parents
8272207c
fecd42d6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
1 deletion
+42
-1
long-frogs-study.md
.changeset/long-frogs-study.md
+5
-0
base-service-v2.ts
packages/common-ts/src/base-service/base-service-v2.ts
+8
-1
service-spec.ts
packages/common-ts/test/service-spec.ts
+29
-0
No files found.
.changeset/long-frogs-study.md
0 → 100644
View file @
e251dac4
---
'
@eth-optimism/common-ts'
:
patch
---
Fix BaseServiceV2 configuration for caseCase options
packages/common-ts/src/base-service/base-service-v2.ts
View file @
e251dac4
...
@@ -211,8 +211,15 @@ export abstract class BaseServiceV2<
...
@@ -211,8 +211,15 @@ export abstract class BaseServiceV2<
// Since BCFG turns everything into lower case, we're required to turn all of the input option
// Since BCFG turns everything into lower case, we're required to turn all of the input option
// names into lower case for the validation step. We'll turn the names back into their original
// names into lower case for the validation step. We'll turn the names back into their original
// names when we're done.
// names when we're done.
const
lowerCaseOptions
=
Object
.
entries
(
params
.
options
).
reduce
(
(
acc
,
[
key
,
val
])
=>
{
acc
[
key
.
toLowerCase
()]
=
val
return
acc
},
{}
)
const
cleaned
=
cleanEnv
<
TOptions
>
(
const
cleaned
=
cleanEnv
<
TOptions
>
(
{
...
config
.
env
,
...
config
.
args
,
...(
params
.
o
ptions
||
{})
},
{
...
config
.
env
,
...
config
.
args
,
...(
lowerCaseO
ptions
||
{})
},
Object
.
entries
(
params
.
optionsSpec
||
{}).
reduce
((
acc
,
[
key
,
val
])
=>
{
Object
.
entries
(
params
.
optionsSpec
||
{}).
reduce
((
acc
,
[
key
,
val
])
=>
{
acc
[
key
.
toLowerCase
()]
=
val
.
validator
({
acc
[
key
.
toLowerCase
()]
=
val
.
validator
({
desc
:
val
.
desc
,
desc
:
val
.
desc
,
...
...
packages/common-ts/test/service-spec.ts
0 → 100644
View file @
e251dac4
import
{
validators
}
from
'
../dist
'
import
{
BaseServiceV2
}
from
'
../src
'
type
ServiceOptions
=
{
camelCase
:
string
}
class
Service
extends
BaseServiceV2
<
ServiceOptions
,
{},
{}
>
{
constructor
(
options
?:
Partial
<
ServiceOptions
>
)
{
super
({
name
:
'
test-service
'
,
version
:
'
0.0
'
,
options
,
optionsSpec
:
{
camelCase
:
{
validator
:
validators
.
str
,
desc
:
'
test
'
},
},
metricsSpec
:
{},
})
}
protected
async
main
()
{
/* eslint-disable @typescript-eslint/no-empty-function */
}
}
describe
(
'
BaseServiceV2
'
,
()
=>
{
it
(
'
base service ctor does not throw on camel case options
'
,
async
()
=>
{
new
Service
({
camelCase
:
'
test
'
})
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment