Extract goog.provide, goog.module, and goog.require namespaces from a JS file.
(path)
| 42 | |
| 43 | |
| 44 | def parse_js_file(path): |
| 45 | """Extract goog.provide, goog.module, and goog.require namespaces from a JS file.""" |
| 46 | with open(path, encoding="utf-8") as f: |
| 47 | content = f.read() |
| 48 | |
| 49 | cleaned = strip_comments(content) |
| 50 | |
| 51 | provides = sorted(PROVIDE_RE.findall(cleaned)) |
| 52 | modules = sorted(MODULE_RE.findall(cleaned)) |
| 53 | requires = sorted(REQUIRE_RE.findall(cleaned)) |
| 54 | |
| 55 | is_module = len(modules) > 0 |
| 56 | all_provides = sorted(set(provides + modules)) |
| 57 | |
| 58 | return all_provides, requires, is_module |
| 59 | |
| 60 | |
| 61 | def main(): |
no test coverage detected