write captured exit code into the right directory (#3334)

* fix(builtin): write captured exit code into the right directory

* buildifier
diff --git a/internal/node/launcher.sh b/internal/node/launcher.sh
index 4f0a7d0..ea5d44b 100644
--- a/internal/node/launcher.sh
+++ b/internal/node/launcher.sh
@@ -152,7 +152,7 @@
     # Captures stderr of the node process to the file specified
     --bazel_capture_stderr=*) STDERR_CAPTURE="${PWD}/${ARG#--bazel_capture_stderr=}" ;;
     # Captures the exit code of the node process to the file specified
-    --bazel_capture_exit_code=*) EXIT_CODE_CAPTURE="${ARG#--bazel_capture_exit_code=}" ;;
+    --bazel_capture_exit_code=*) EXIT_CODE_CAPTURE="${PWD}/${ARG#--bazel_capture_exit_code=}" ;;
     # Disable the node_loader.js monkey patches for require()
     # Note that this means you need an explicit runfiles helper library
     # This flag is now a no-op since the default is also false
diff --git a/internal/node/test/chdir/BUILD.bazel b/internal/node/test/chdir/BUILD.bazel
index c105a45..9215161 100644
--- a/internal/node/test/chdir/BUILD.bazel
+++ b/internal/node/test/chdir/BUILD.bazel
@@ -3,7 +3,7 @@
 # the project when you call them.
 # See https://github.com/bazelbuild/rules_nodejs/issues/1840
 
-load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary", "nodejs_test", "npm_package_bin")
+load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test", "nodejs_binary", "nodejs_test", "npm_package_bin")
 
 # Trivial tool that expects to run in source directory under the package
 nodejs_binary(
@@ -25,10 +25,17 @@
     args = ["/".join([".."] * _package_segments + ["$@"])],
     chdir = package_name(),
     data = ["_package.json"],
+    exit_code_out = "exit.code",
     stdout = "do_copy.log",
     tool = ":tool_cp",
 )
 
+generated_file_test(
+    name = "exit_code_test",
+    src = "exit_code_test.golden",
+    generated = ":exit.code",
+)
+
 # Trivial tool to mock react-scripts
 nodejs_binary(
     name = "tool_bin",
diff --git a/internal/node/test/chdir/exit_code_test.golden b/internal/node/test/chdir/exit_code_test.golden
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/internal/node/test/chdir/exit_code_test.golden
@@ -0,0 +1 @@
+0