Skip to content

Commit 5e4d6b3

Browse files
evie404pcj
authored andcommitted
updates to support latest bazel (0.23.0) (#78)
* use native.package_name() instead of PACKAGE_NAME * remove cfg = "data" no-op * test latest bazels * stop using FileType for Bazel 0.24.0
1 parent e119534 commit 5e4d6b3

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ os:
88
- osx
99

1010
env:
11-
- V=0.7.0
12-
- V=0.6.1
13-
- V=0.5.4
14-
- V=0.5.3
11+
- V=0.20.0
12+
- V=0.21.0
13+
- V=0.22.0
14+
- V=0.23.2
15+
- V=0.24.0
1516

1617
before_install:
1718
- OS=linux

node/internal/mocha_test.bzl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def mocha_test(
2626
executable with the name of the testable entrypoint module.
2727
2828
"""
29-
29+
3030
node_module(
3131
name = name + "_module",
3232
main = main,
@@ -45,12 +45,12 @@ def mocha_test(
4545
"%s_modules" % name,
4646
"node_modules"
4747
]
48-
49-
if PACKAGE_NAME:
50-
entrypoint.insert(0, PACKAGE_NAME)
51-
entrypoint.append(PACKAGE_NAME)
48+
49+
if native.package_name():
50+
entrypoint.insert(0, native.package_name())
51+
entrypoint.append(native.package_name())
5252
entrypoint.append("%s_module" % name)
53-
53+
5454
native.sh_test(
5555
name = name,
5656
srcs = [script],

node/internal/node_module.bzl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
_node_filetype = FileType([".js", ".node"])
1+
_node_filetype = [".js", ".node"]
22

33

44
def _relname(ctx, root_file, file):
@@ -13,13 +13,13 @@ def _relname(ctx, root_file, file):
1313
rel = file.path[len(root_file.dirname):]
1414
return rel
1515

16-
16+
1717
if not file.short_path.startswith(ctx.label.package):
1818
fail("_relname failed: %s must start with %s" % (file.short_path, ctx.label.package))
1919

2020
# All others, shave off the package label from the file's short
2121
# path.
22-
rel = file.short_path[len(ctx.label.package):]
22+
rel = file.short_path[len(ctx.label.package):]
2323
if rel.startswith('/'):
2424
rel = rel[1:]
2525

@@ -65,7 +65,7 @@ def _create_package_json(ctx, name, files, executables):
6565

6666
if executables:
6767
json["bin"] = executables
68-
68+
6969
if ctx.attr.main:
7070
json["main"] = ctx.file.main.basename
7171

@@ -132,7 +132,7 @@ def _node_module_impl(ctx):
132132
files.append(ctx.file.main)
133133

134134
executables = ctx.attr.executables
135-
135+
136136
package_json = ctx.file.package_json
137137

138138
# The presence of an index file suppresses creation of the
@@ -226,15 +226,14 @@ node_module = rule(
226226
# the module. If not present, one will be generated UNLESS an
227227
# index file is provided.
228228
"package_json": attr.label(
229-
allow_files = FileType(["package.json"]),
229+
allow_files = ["package.json"],
230230
single_file = True,
231231
),
232232

233233
# Additional data files to be included in the module, but
234234
# excluded from the package.json 'files' attribute.
235235
"data": attr.label_list(
236236
allow_files = True,
237-
cfg = "data",
238237
),
239238

240239
# Module dependencies.

node/internal/yarn_modules.bzl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ def _yarn_modules_impl(ctx):
4343
sha256 = "472add7ad141c75811f93dca421e2b7456045504afacec814b0565f092156250",
4444
stripPrefix = "package",
4545
)
46-
46+
4747
# Copy over or create the package.json file
4848
if ctx.attr.package_json:
4949
package_json_file = ctx.path(ctx.attr.package_json)
5050
execute(ctx, ["cp", package_json_file, "package.json"])
5151
else:
5252
ctx.file("package.json", _create_package_json_content(ctx).to_json())
5353

54-
54+
5555
# Copy the parse_yarn_lock script and yarn.js over here.
5656
execute(ctx, ["cp", parse_yarn_lock_js, "internal/parse_yarn_lock.js"])
5757
execute(ctx, ["cp", clean_node_modules_js, "internal/clean_node_modules.js"])
@@ -64,7 +64,7 @@ def _yarn_modules_impl(ctx):
6464
fail("Required install tool '%s' is not in the PATH" % tool, "install_tools")
6565
install_path.append(tool_path.dirname)
6666
install_path.append("$PATH")
67-
67+
6868
# Build node_modules via 'yarn install'
6969
execute(ctx, [node, yarn_js, "install"], quiet = True, environment = {
7070
"PATH": ":".join(install_path),
@@ -73,7 +73,7 @@ def _yarn_modules_impl(ctx):
7373
# Sadly, pre-existing BUILD.bazel files located in npm modules can
7474
# screw up package boudaries. Remove these.
7575
execute(ctx, [node, "internal/clean_node_modules.js"], quiet = True)
76-
76+
7777
# Run the script and save the stdout to our BUILD file(s)
7878
parse_args = ["--resolve=%s:%s" % (k, v) for k, v in ctx.attr.resolutions.items()]
7979
result = execute(ctx, [node, "internal/parse_yarn_lock.js"] + parse_args, quiet = True)
@@ -130,11 +130,11 @@ yarn_modules = repository_rule(
130130
single_file = True,
131131
),
132132
# If specififed, augment the PATH environment variable with these
133-
# tools during 'yarn install'.
133+
# tools during 'yarn install'.
134134
"install_tools": attr.string_list(),
135135
"package_json": attr.label(
136136
mandatory = False,
137-
allow_files = FileType(["package.json"]),
137+
allow_files = ["package.json"],
138138
),
139139
"post_install": attr.string_list(),
140140
"deps": attr.string_dict(mandatory = False),

0 commit comments

Comments
 (0)