Skip to content

Commit

Permalink
bugfix Regex Bug (#21)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Michael Waddell <michael@waddellnet.com>
  • Loading branch information
github-actions[bot] and mwaddell authored Apr 19, 2023
1 parent 79cef4e commit 9bde17a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions salt2type
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,8 @@ def to_type(raw_type: str) -> str:
raw_type = re.sub(r"\bdynamic\b", "any", raw_type)
raw_type = re.sub(r"\bDelegate\b", "Action<void>", raw_type)
raw_type = re.sub(r"^delegate (.*)$", r"Action<\1>", raw_type)
raw_type = re.sub(r"(ss\.)?(Js)?Dictionary<", r"Record<", raw_type)
raw_type = re.sub(r"(ss\.)?(Js)?Dictionary([^<)", r"Record<string,unknown>\1", raw_type)
raw_type = re.sub(r"(ss\.)?(Js)?Dictionary\<", r"Record<", raw_type)
raw_type = re.sub(r"(ss\.)?(Js)?Dictionary([^<])", r"Record<string,unknown>1", raw_type)
raw_type = re.sub(r"^(sealed override|override|params|readonly|new|this|abstract|const) ", "", raw_type)

if optional:
Expand Down Expand Up @@ -663,8 +663,16 @@ def copy_tpl(out_dir: str, asm_name: str, ns_name: str) -> None:
@param ns_name: The namespace to export for external use
"""
tpl_dir = os.path.join(os.path.dirname(sys.argv[0]), "tpl")
ignored_dirs = list(map(lambda f: os.path.join(tpl_dir, f), ("coverage", "dist", "node_modules")))

def is_ignored(dir_name: str) -> bool:
for ignored_dir in ignored_dirs:
if dir_name.startswith(ignored_dir):
return True
return False

for src_dir, _, files in os.walk(tpl_dir):
if "node_modules" not in src_dir:
if not is_ignored(src_dir):
dst_dir = src_dir.replace(tpl_dir, out_dir, 1)
if not os.path.exists(dst_dir):
os.makedirs(dst_dir)
Expand Down

0 comments on commit 9bde17a

Please sign in to comment.