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
2b5b8c1a
Unverified
Commit
2b5b8c1a
authored
Mar 13, 2023
by
inphi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(cmn): BaseServiceV2 throws on camelCase options
parent
9ae0a566
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletion
+38
-1
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
+30
-0
No files found.
packages/common-ts/src/base-service/base-service-v2.ts
View file @
2b5b8c1a
...
@@ -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 @
2b5b8c1a
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
()
=>
{
// throws on error
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