forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract_typings_rule.bzl
More file actions
26 lines (21 loc) · 955 Bytes
/
Copy pathextract_typings_rule.bzl
File metadata and controls
26 lines (21 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""Starlark file that exposes a rule for extracting type definitions of dependencies."""
load("@build_bazel_rules_nodejs//:providers.bzl", "DeclarationInfo")
def _extract_typings_rule_impl(ctx):
"""Implementation of the `extract_typings` rule."""
transitive_depsets = []
for dep in ctx.attr.deps:
# Based on whether declarations should be collected, extract direct
# and transitive declaration files using the `DeclarationInfo` provider.
if DeclarationInfo in dep:
transitive_depsets.append(dep[DeclarationInfo].transitive_declarations)
return [DefaultInfo(files = depset(transitive = transitive_depsets))]
# TODO: Move into shared dev-infra package.
extract_typings = rule(
implementation = _extract_typings_rule_impl,
doc = """Rule that extracts all transitive typings of dependencies""",
attrs = {
"deps": attr.label_list(
allow_files = True,
),
},
)