Skip to content

Commit

Permalink
Fix fs.copyFileSync EACCES: permission denied failure (bazel-contri…
Browse files Browse the repository at this point in the history
…b#546)

* Fix for web_package fs.copyFileSync issue

* Address review comment
  • Loading branch information
gregmagolan authored Feb 13, 2019
1 parent 92b7684 commit fe4925c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 6 additions & 1 deletion internal/web_package/assembler.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ function main(params) {
}
}

for (const f of params) {
// Remove duplicate files (which may come from this rule) from the
// list since fs.copyFileSync may fail with `EACCES: permission denied`
// as it will not have permission to overwrite duplicate files that were
// copied from within bazel-bin.
// See https://github.com/bazelbuild/rules_nodejs/pull/546.
for (const f of new Set(params)) {
copy(f);
}
return 0;
Expand Down
14 changes: 12 additions & 2 deletions internal/web_package/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test", "rollup_bundle")
load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package")

rollup_bundle(
name = "bundle",
srcs = glob(["*.js"]),
entry_point = "internal/web_package/test/script.js",
)

web_package(
name = "pkg",
assets = ["script.js"],
# Intentionally duplicating `bundle.min.js` in assets and data
# to test for regression of the issues fixed by
# https://github.com/bazelbuild/rules_nodejs/pull/546
assets = [":bundle.min.js"],
data = [":bundle"],
index_html = "index.html",
)

Expand Down
2 changes: 1 addition & 1 deletion internal/web_package/test/index_golden.html_
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<html><head></head><body>
<script type="text/javascript" src="/script.js?v=123"></script></body></html>
<script type="text/javascript" src="/bundle.min.js?v=123"></script></body></html>

0 comments on commit fe4925c

Please sign in to comment.