Skip to content

Commit

Permalink
Merge pull request #589 from pixiv/mimo/fix-token-cli
Browse files Browse the repository at this point in the history
fix(token-cli): primitive token named negative value case
  • Loading branch information
mimokmt authored Jul 10, 2024
2 parents e542eb0 + fa34318 commit 91cb19b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/token-cli/src/transformer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const transformer = (token) => {
.toLowerCase()
.replaceAll('/', '-')
.replaceAll(' ', '-')
.replaceAll('--', '-')
.replace(/(--)(\D)/g, '-$2')
}

module.exports = {
Expand Down
10 changes: 10 additions & 0 deletions packages/token-cli/src/transformer/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ test('tests transformer real case', () => {
'color-container-secondary-default-a'
)
})
test('tests transformer negative primitive value case', () => {
expect(transformer({ path: ['Colors', 'Dark/Neutral/-10'] })).toBe(
'colors-dark-neutral--10'
)
})
test('tests transformer negative primitive value unreal case', () => {
expect(transformer({ path: ['Colors', 'dark/neutralABCDEF/-10'] })).toBe(
'colors-dark-neutral-a-b-c-d-e-f--10'
)
})
test('tests transformer unreal case', () => {
expect(
transformer({ path: ['Color', 'Container/Secondary/DefaultABCDEF'] })
Expand Down

0 comments on commit 91cb19b

Please sign in to comment.