Skip to content

Commit

Permalink
refactor(builtin): renamed pkg_npm rename_build_files to hide_build_f…
Browse files Browse the repository at this point in the history
…iles
  • Loading branch information
gregmagolan authored and alexeagle committed Dec 19, 2019
1 parent 60bcc1d commit ddbae15
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pkg_npm(
],
# Don't rename BUILD files as this package is not published to npm
# but is compressed in "release" below and published as a .tar.gz to GitHub
rename_build_files = False,
hide_build_files = False,
# Don't replace the default 0.0.0-PLACEHOLDER for this pkg_npm since
# we are packaging up the packager itself and this replacement will break it
replace_with_version = "",
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg_npm/packager.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ function main(args) {
args = fs.readFileSync(args[0], {encoding: 'utf-8'}).split('\n').map(unquoteArgs);
const
[outDir, baseDir, srcsArg, binDir, genDir, depsArg, packagesArg, substitutionsArg, packPath,
publishPath, replaceWithVersion, stampFile, vendorExternalArg, renameBuildFilesArg,
publishPath, replaceWithVersion, stampFile, vendorExternalArg, hideBuildFilesArg,
runNpmTemplatePath] = args;
const renameBuildFiles = parseInt(renameBuildFilesArg);
const renameBuildFiles = parseInt(hideBuildFilesArg);

const substitutions = [
// Strip content between BEGIN-INTERNAL / END-INTERNAL comments
Expand Down
18 changes: 11 additions & 7 deletions internal/pkg_npm/pkg_npm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def create_package(ctx, deps_sources, nested_packages):
args.add(ctx.attr.replace_with_version)
args.add(ctx.version_file.path if stamp else "")
args.add_joined(ctx.attr.vendor_external, join_with = ",", omit_if_empty = False)
args.add("1" if ctx.attr.rename_build_files else "0")
args.add("1" if ctx.attr.hide_build_files else "0")

# require.resolve expects the path to start with the workspace name and not "external"
run_npm_template_path = strip_external(ctx.file._run_npm_template.path)
Expand Down Expand Up @@ -123,6 +123,16 @@ PKG_NPM_ATTRS = {
doc = """Files inside this directory which are simply copied into the package.""",
allow_files = True,
),
"hide_build_files": attr.bool(
doc = """If set BUILD and BUILD.bazel files are prefixed with `_` in the npm package.
The default is True since npm packages that contain BUILD files don't work with
`yarn_install` and `npm_install` without a post-install step that deletes or renames them.
NB: Bazel has a change in https://github.com/bazelbuild/bazel/pull/10261
(expected in version 2.1) that adds .bazelignore
support for external repositories, which will make this attribute obsolete.""",
default = True,
),
"nested_packages": attr.label_list(
doc = """Other pkg_npm rules whose content is copied into this package.""",
allow_files = True,
Expand All @@ -132,12 +142,6 @@ PKG_NPM_ATTRS = {
providers = [NodeContextInfo],
doc = "Internal use only",
),
"rename_build_files": attr.bool(
doc = """If set BUILD and BUILD.bazel files are prefixed with `_` in the npm package.
The default is True since npm packages that contain BUILD files don't work with
`yarn_install` and `npm_install` without a post-install step that deletes or renames them.""",
default = True,
),
"replace_with_version": attr.string(
doc = """If set this value is replaced with the version stamp data.
See the section on stamping in the README.""",
Expand Down

0 comments on commit ddbae15

Please sign in to comment.