From 5b74f064545ddd326ef3023bb760471b71d987a6 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Mon, 8 Apr 2019 19:57:51 -0700 Subject: [PATCH] Don't generate empty `scripts = []` in generated build files --- internal/npm_install/generate_build_file.js | 14 +++++++++----- .../@gregmagolan/test-a/BUILD.bazel.golden | 3 --- .../@gregmagolan/test-b/BUILD.bazel.golden | 3 --- .../golden/node_modules/ajv/BUILD.bazel.golden | 3 --- .../golden/node_modules/jasmine/BUILD.bazel.golden | 3 --- .../golden/node_modules/rxjs/BUILD.bazel.golden | 3 --- .../golden/node_modules/unidiff/BUILD.bazel.golden | 3 --- .../golden/node_modules/zone.js/BUILD.bazel.golden | 3 --- 8 files changed, 9 insertions(+), 26 deletions(-) diff --git a/internal/npm_install/generate_build_file.js b/internal/npm_install/generate_build_file.js index 2b68b87d87..046874eacd 100644 --- a/internal/npm_install/generate_build_file.js +++ b/internal/npm_install/generate_build_file.js @@ -697,9 +697,16 @@ function printPackage(pkg) { // TODO(gmagolan): add UMD & AMD scripts to scripts even if not an APF package _but_ only if they // are named? const scripts = getNgApfScripts(pkg); - const pkgDeps = pkg._dependencies.filter(dep => dep !== pkg && !dep._isNested); + let scriptStarlark = ''; + if (scripts.length) { + scriptStarlark = ` + scripts = [ + ${scripts.map(f => `":${f}",`).join('\n ')} + ],`; + } + let result = `load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary") load("@build_bazel_rules_nodejs//internal/npm_install:node_module_library.bzl", "node_module_library") @@ -725,10 +732,7 @@ node_module_library( name = "${pkg._name}__files", srcs = [ ${sources.map(f => `":${f}",`).join('\n ')} - ], - scripts = [ - ${scripts.map(f => `":${f}",`).join('\n ')} - ], + ],${scriptStarlark} ) node_module_library( diff --git a/internal/npm_install/test/golden/node_modules/@gregmagolan/test-a/BUILD.bazel.golden b/internal/npm_install/test/golden/node_modules/@gregmagolan/test-a/BUILD.bazel.golden index 71eb172542..00b5b15cdb 100644 --- a/internal/npm_install/test/golden/node_modules/@gregmagolan/test-a/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/node_modules/@gregmagolan/test-a/BUILD.bazel.golden @@ -18,9 +18,6 @@ node_module_library( ":main.js", ":package.json", ], - scripts = [ - - ], ) node_module_library( name = "test-a__typings", diff --git a/internal/npm_install/test/golden/node_modules/@gregmagolan/test-b/BUILD.bazel.golden b/internal/npm_install/test/golden/node_modules/@gregmagolan/test-b/BUILD.bazel.golden index 13530d88a0..8c4bcaea02 100644 --- a/internal/npm_install/test/golden/node_modules/@gregmagolan/test-b/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/node_modules/@gregmagolan/test-b/BUILD.bazel.golden @@ -19,9 +19,6 @@ node_module_library( ":node_modules/@gregmagolan/test-a/package.json", ":package.json", ], - scripts = [ - - ], ) node_module_library( name = "test-b__typings", diff --git a/internal/npm_install/test/golden/node_modules/ajv/BUILD.bazel.golden b/internal/npm_install/test/golden/node_modules/ajv/BUILD.bazel.golden index 42c2af409f..94ef264227 100644 --- a/internal/npm_install/test/golden/node_modules/ajv/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/node_modules/ajv/BUILD.bazel.golden @@ -106,9 +106,6 @@ node_module_library( ":scripts/prepare-tests", ":scripts/travis-gh-pages", ], - scripts = [ - - ], ) node_module_library( name = "ajv__typings", diff --git a/internal/npm_install/test/golden/node_modules/jasmine/BUILD.bazel.golden b/internal/npm_install/test/golden/node_modules/jasmine/BUILD.bazel.golden index a09d8b3627..6a1fe128ac 100644 --- a/internal/npm_install/test/golden/node_modules/jasmine/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/node_modules/jasmine/BUILD.bazel.golden @@ -40,9 +40,6 @@ node_module_library( ":package.json", ":tasks/jasmine.js", ], - scripts = [ - - ], ) node_module_library( name = "jasmine__typings", diff --git a/internal/npm_install/test/golden/node_modules/rxjs/BUILD.bazel.golden b/internal/npm_install/test/golden/node_modules/rxjs/BUILD.bazel.golden index 225a012d79..a300bbc213 100644 --- a/internal/npm_install/test/golden/node_modules/rxjs/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/node_modules/rxjs/BUILD.bazel.golden @@ -3572,9 +3572,6 @@ node_module_library( ":webSocket/index.js.map", ":webSocket/package.json", ], - scripts = [ - - ], ) node_module_library( name = "rxjs__typings", diff --git a/internal/npm_install/test/golden/node_modules/unidiff/BUILD.bazel.golden b/internal/npm_install/test/golden/node_modules/unidiff/BUILD.bazel.golden index c6bda34b02..7e8d7af2ec 100644 --- a/internal/npm_install/test/golden/node_modules/unidiff/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/node_modules/unidiff/BUILD.bazel.golden @@ -25,9 +25,6 @@ node_module_library( ":test/test_unidiff.js", ":unidiff.js", ], - scripts = [ - - ], ) node_module_library( name = "unidiff__typings", diff --git a/internal/npm_install/test/golden/node_modules/zone.js/BUILD.bazel.golden b/internal/npm_install/test/golden/node_modules/zone.js/BUILD.bazel.golden index 0e1e0ea02f..ecc96b9f2c 100644 --- a/internal/npm_install/test/golden/node_modules/zone.js/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/node_modules/zone.js/BUILD.bazel.golden @@ -143,9 +143,6 @@ node_module_library( ":lib/zone.ts", ":package.json", ], - scripts = [ - - ], ) node_module_library( name = "zone.js__typings",