MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / parse_javascript_modules

Function parse_javascript_modules

Scripts/Other Tools/Termux Repair Wizard.py:1066–1085  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

1064
1065
1066def parse_javascript_modules(text):
1067 modules = set()
1068 patterns = [
1069 r"\brequire\s*\(\s*['\"]([^'\"]+)['\"]\s*\)",
1070 r"\bfrom\s+['\"]([^'\"]+)['\"]",
1071 r"\bimport\s*\(\s*['\"]([^'\"]+)['\"]\s*\)",
1072 r"\bimport\s+['\"]([^'\"]+)['\"]",
1073 ]
1074 for pattern in patterns:
1075 modules.update(re.findall(pattern, text))
1076 result = set()
1077 for module in modules:
1078 if module.startswith((".", "/", "node:")) or module in NODE_BUILTINS:
1079 continue
1080 if module.startswith("@"):
1081 parts = module.split("/")
1082 result.add("/".join(parts[:2]))
1083 else:
1084 result.add(module.split("/")[0])
1085 return result
1086
1087
1088def check_javascript_script(path, language, text, root, auto_install, report, processed_manifests):

Callers 1

check_javascript_scriptFunction · 0.70

Calls 1

addMethod · 0.45

Tested by

no test coverage detected