Repository navigation
Expand file tree
/
Copy pathdefaults.bzl
More file actions
73 lines (58 loc) · 2.08 KB
/
Copy pathdefaults.bzl
File metadata and controls
73 lines (58 loc) · 2.08 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""Wrappers around build rules
These set common default attributes and behaviors for our local repo
"""
load(
"@build_bazel_rules_nodejs//:index.bzl",
_COMMON_REPLACEMENTS = "COMMON_REPLACEMENTS",
_nodejs_test = "nodejs_test",
_npm_package = "npm_package",
)
load("@rules_codeowners//tools:codeowners.bzl", _codeowners = "codeowners")
nodejs_test = _nodejs_test
def npm_package(**kwargs):
"Set some defaults for the npm_package rule"
# Every package should have a copy of the root LICENSE file
native.genrule(
name = "copy_LICENSE",
srcs = ["@build_bazel_rules_nodejs//:LICENSE"],
outs = ["LICENSE"],
cmd = "cp $< $@",
)
deps = kwargs.pop("deps", [])
deps.append(":copy_LICENSE")
# Make every package visible to tests
visibility = kwargs.pop("visibility", [
"//e2e:__pkg__",
"//examples:__pkg__",
])
# Default replacements to scrub things like skylib references
replacements = kwargs.pop("replacements", _COMMON_REPLACEMENTS)
# Finally call through to the rule with our defaults set
_npm_package(
deps = deps,
replacements = replacements,
visibility = visibility,
**kwargs
)
_GLOBAL_OWNERS = "@alexeagle"
def codeowners(name = "OWNERS", no_parent = False, **kwargs):
"""Convenience macro to set some defaults
Args:
no_parent: Mimic the google3 OWNERS file which allows a .no-parent rule to avoid inheriting global approvers, see http://go/owners#noparent
**kwargs: see codeowners rule docs
"""
pkg = native.package_name()
teams = [kwargs.pop("team")] if "team" in kwargs.keys() else kwargs.pop("teams", [])
patterns = kwargs.pop("patterns") if "patterns" in kwargs.keys() else [kwargs.pop("pattern", "**")]
if pkg.startswith("."):
print(pkg, name)
# Googlers: see http://go/owners#noparent
if not no_parent:
teams.append(_GLOBAL_OWNERS)
_codeowners(
name = name,
patterns = patterns,
teams = teams,
visibility = ["//.github:__pkg__"],
**kwargs
)