Skip to content

Commit

Permalink
fix(devkit): uppercase constant name correct transformation (#17046)
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarini authored May 16, 2023
1 parent 88b263b commit 9866595
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/devkit/src/utils/names.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ describe('names', () => {
expect(names('foo-@bar').constantName).toEqual('FOO_BAR');
expect(names(' foo bar').constantName).toEqual('FOO_BAR');
expect(names('_foo_bar').constantName).toEqual('FOO_BAR');
expect(names('FOO_BAR').constantName).toEqual('FOO_BAR');
});
});
3 changes: 2 additions & 1 deletion packages/devkit/src/utils/names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ function toPropertyName(s: string): string {
* Hyphenated to CONSTANT_CASE
*/
function toConstantName(s: string): string {
return toFileName(toPropertyName(s))
const normalizedS = s.toUpperCase() === s ? s.toLowerCase() : s;
return toFileName(toPropertyName(normalizedS))
.replace(/([^a-zA-Z0-9])/g, '_')
.toUpperCase();
}
Expand Down

1 comment on commit 9866595

@vercel
Copy link

@vercel vercel bot commented on 9866595 May 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev

Please sign in to comment.