...

Text file src/github.com/bazelbuild/buildtools/buildifier/npm/BUILD.bazel

Documentation: github.com/bazelbuild/buildtools/buildifier/npm

     1load("@aspect_rules_js//js:defs.bzl", "js_test")
     2load("@aspect_rules_js//npm:defs.bzl", "npm_package", "stamped_package_json")
     3load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
     4
     5copy_file(
     6    name = "copy_LICENSE",
     7    src = "//:LICENSE",
     8    out = "LICENSE",
     9)
    10
    11genrule(
    12    name = "buildifier_launcher",
    13    srcs = ["//:launcher.js"],
    14    outs = ["buildifier.js"],
    15    cmd = "sed s/_TOOL_/buildifier/ $< > $@",
    16)
    17
    18# npm rules live in this subdirectory to avoid a load() statement
    19# in the parent package leaking to users. This means we need
    20# to copy the output files so the pkg_npm will find them in the
    21# output directory for this package.
    22_PARENT_PACKAGE_FILES = [
    23    "README.md",
    24    "buildifier-darwin_amd64",
    25    "buildifier-darwin_arm64",
    26    "buildifier-linux_amd64",
    27    "buildifier-linux_arm64",
    28    "buildifier-windows_amd64.exe",
    29]
    30
    31[
    32    copy_file(
    33        name = "copy_%s" % s,
    34        # go_binary doesn't give a predeclared output for
    35        # the file in "out" so we have to construct a
    36        # label to reference the go_binary rule itself.
    37        src = "//buildifier:%s" % s.replace("_arm64", "-arm64").split("_amd64")[0],
    38        out = s,
    39    )
    40    for s in _PARENT_PACKAGE_FILES
    41]
    42
    43stamped_package_json(
    44    name = "package",
    45    stamp_var = "BUILD_SCM_VERSION",
    46)
    47
    48npm_package(
    49    name = "buildifier",
    50    srcs = [
    51        "LICENSE",
    52        "buildifier.js",
    53        ":package",
    54    ] + _PARENT_PACKAGE_FILES,
    55    package = "@bazel/buildifier",
    56)
    57
    58js_test(
    59    name = "integration_test",
    60    data = [":buildifier"],
    61    entry_point = "test.js",
    62)

View as plain text