-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(builtin): only generate a .tar pkg_npm output when requested (#2428)
- Loading branch information
Showing
6 changed files
with
110 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm") | ||
|
||
pkg_npm( | ||
name = "pkg", | ||
srcs = [ | ||
"main.js", | ||
"package.json", | ||
], | ||
tgz = "my_tar.tgz", | ||
) | ||
|
||
sh_test( | ||
name = "pkg_test", | ||
size = "small", | ||
srcs = [ | ||
"test.sh", | ||
], | ||
data = [ | ||
"my_tar.tgz", | ||
"//third_party/github.com/bazelbuild/bazel-skylib:tests/unittest.bash", | ||
], | ||
# Disabled on windows due to how tar interprets the colons in file paths as remotes, and the --force-local | ||
# only being an option in GNU tar... | ||
# This feature has additional coverage as it used by all bazel tests for examples | ||
tags = [ | ||
"fix-windows", | ||
], | ||
deps = [ | ||
"@build_bazel_rules_nodejs//third_party/github.com/bazelbuild/bazel/tools/bash/runfiles", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const MAIN = 'MAIN'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "awesome-package", | ||
"private": true, | ||
"version": "0.0.0-PLACEHOLDER" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# --- begin runfiles.bash initialization v2 --- | ||
# Copy-pasted from the Bazel Bash runfiles library v2. | ||
set -uo pipefail; f=build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash | ||
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ | ||
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ | ||
source "$0.runfiles/$f" 2>/dev/null || \ | ||
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ | ||
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ | ||
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e | ||
# --- end runfiles.bash initialization v2 --- | ||
|
||
source "$(rlocation build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel-skylib/tests/unittest.bash)" \ | ||
|| { echo "Could not source build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel-skylib/tests/unittest.bash" >&2; exit 1; } | ||
|
||
function test_tgz_package_json() { | ||
TGZ=$(rlocation build_bazel_rules_nodejs/internal/pkg_npm/test/tgz_out/my_tar.tgz) | ||
tar -vxf "${TGZ}" | ||
|
||
assert_contains "awesome-package" "./package/package.json" | ||
assert_contains "MAIN" "./package/main.js" | ||
} | ||
|
||
run_suite "test_tgz_package_json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters