fix(bazel): Install angular repo before yarn_install (#28670)

PR closes https://github.com/angular/angular/issues/28636

PR Close #28670
This commit is contained in:
Keen Yee Liau 2019-02-13 09:44:54 +08:00 committed by Miško Hevery
parent 0c7581da89
commit 49fb8c3cb0
2 changed files with 4 additions and 18 deletions

View File

@ -6,7 +6,7 @@ const fs = require('fs');
function replaceAngular(content) {
const regex = /ANGULAR_VERSION.*\nhttp_archive\((.*\n){4}\)/;
if (!regex.test(content)) {
throw new Error("Failed to find http_archive rule for Angular in WORKSPACE");
throw new Error('Failed to find http_archive rule for Angular in WORKSPACE');
}
return content.replace(regex, `
local_repository(
@ -15,22 +15,6 @@ local_repository(
)`);
}
function replaceNpm(content) {
const regex = /yarn_install\((.*\n){4}\)/;
if (!regex.test(content)) {
throw new Error("Failed to find yarn_install rule for Angular in WORKSPACE");
}
return content.replace(regex, `
yarn_install(
name = "npm",
# Need a reference to @angular here so that Bazel sets up the
# external repository before calling yarn_install
data = ["@angular//:LICENSE"],
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)`);
}
function main(argv) {
argv = argv.slice(2);
if (argv.length !== 1) {
@ -39,7 +23,6 @@ function main(argv) {
const workspace = argv[0];
let content = fs.readFileSync(workspace, 'utf-8');
content = replaceAngular(content);
content = replaceNpm(content);
fs.writeFileSync(workspace, content);
}

View File

@ -52,6 +52,9 @@ check_bazel_version("0.18.0")
node_repositories()
yarn_install(
name = "npm",
# Need a reference to @angular here so that Bazel sets up the
# external repository before calling yarn_install
data = ["@angular//:LICENSE"],
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)