(text)
| 1064 | |
| 1065 | |
| 1066 | def 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 | |
| 1088 | def check_javascript_script(path, language, text, root, auto_install, report, processed_manifests): |
no test coverage detected