Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure BAZEL_NODE_RUNFILES_HELPER & BAZEL_NODE_PATCH_REQUIRE are absolute #1634

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/node/launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,16 @@ fi

# Export the location of the runfiles helpers script
export BAZEL_NODE_RUNFILES_HELPER=$(rlocation "TEMPLATED_runfiles_helper_script")
if [[ "${BAZEL_NODE_RUNFILES_HELPER}" != /* ]] && [[ ! "${BAZEL_NODE_RUNFILES_HELPER}" =~ ^[A-Z]:[\\/] ]]; then
export BAZEL_NODE_RUNFILES_HELPER=$(pwd)/${BAZEL_NODE_RUNFILES_HELPER}
fi

# Export the location of the require patch script as it can be used to boostrap
# node require patch if needed
export BAZEL_NODE_PATCH_REQUIRE=$(rlocation "TEMPLATED_require_patch_script")
if [[ "${BAZEL_NODE_PATCH_REQUIRE}" != /* ]] && [[ ! "${BAZEL_NODE_PATCH_REQUIRE}" =~ ^[A-Z]:[\\/] ]]; then
export BAZEL_NODE_PATCH_REQUIRE=$(pwd)/${BAZEL_NODE_PATCH_REQUIRE}
fi

# The main entry point
MAIN=$(rlocation "TEMPLATED_loader_script")
Expand Down
19 changes: 19 additions & 0 deletions internal/node/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,25 @@ golden_file_test(
golden = "expand_variables.golden",
)

nodejs_binary(
name = "test_runfiles_helper",
data = [":test_runfiles_helper.golden"],
entry_point = "test_runfiles_helper.js",
)

npm_package_bin(
name = "test_runfiles_helper_ouput",
outs = ["test_runfiles_helper.out"],
args = ["$@"],
tool = ":test_runfiles_helper",
)

golden_file_test(
name = "test_runfiles_helper_test",
actual = ":test_runfiles_helper.out",
golden = "test_runfiles_helper.golden",
)

nodejs_test(
name = "fail_test",
entry_point = "fail.spec.js",
Expand Down
1 change: 1 addition & 0 deletions internal/node/test/test_runfiles_helper.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello_world
7 changes: 7 additions & 0 deletions internal/node/test/test_runfiles_helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const fs = require('fs');
const args = process.argv.slice(2);
const outfile = args.shift();
const runfiles = require(process.env['BAZEL_NODE_RUNFILES_HELPER']);
const golden =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line looks strange, lots of spaces for some reason?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang format did that for line length I think

runfiles.resolve('build_bazel_rules_nodejs/internal/node/test/test_runfiles_helper.golden');
fs.writeFileSync(outfile, fs.readFileSync(golden, 'utf-8'), 'utf-8');