diff --git a/packages/token-cli/src/transformer/index.js b/packages/token-cli/src/transformer/index.js index aeed1061f..9296cc2f1 100644 --- a/packages/token-cli/src/transformer/index.js +++ b/packages/token-cli/src/transformer/index.js @@ -10,7 +10,7 @@ const transformer = (token) => { .toLowerCase() .replaceAll('/', '-') .replaceAll(' ', '-') - .replaceAll('--', '-') + .replace(/(--)(\D)/g, '-$2') } module.exports = { diff --git a/packages/token-cli/src/transformer/index.test.js b/packages/token-cli/src/transformer/index.test.js index 189d62f44..ce9270c9c 100644 --- a/packages/token-cli/src/transformer/index.test.js +++ b/packages/token-cli/src/transformer/index.test.js @@ -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'] })