Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[js] convert camelCase and snake_case to BIG_SNAKE_CASE #14490

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from
7 changes: 5 additions & 2 deletions javascript/private/gen_file.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
import re

_copyright = """/*
* Copyright 2011-2014 Software Freedom Conservancy
Expand All @@ -19,9 +20,11 @@
"""

def get_atom_name(name):
# TODO: Convert camelCase and snake_case to BIG_SNAKE_CASE
# Convert camelCase and snake_case to BIG_SNAKE_CASE
name = os.path.basename(name)
return name.upper()
name = re.sub(r'(?<!^)(?<![_-])(?=[A-Z])', '_', name).lower()
name = name.replace('-', '_').upper()
return name

def write_atom_literal(out, name, contents, lang, utf8):
# Escape the contents of the file so it can be stored as a literal.
Expand Down