build: fix for integration test bazel-schematics (#28532)
PR Close #28532
This commit is contained in:
parent
62c0deac42
commit
ebaceb37e0
@ -3,23 +3,44 @@
|
|||||||
|
|
||||||
const fs = require('fs');
|
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");
|
||||||
|
}
|
||||||
|
return content.replace(regex, `
|
||||||
|
local_repository(
|
||||||
|
name = "angular",
|
||||||
|
path = "../../..",
|
||||||
|
)`);
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
function main(argv) {
|
||||||
argv = argv.slice(2);
|
argv = argv.slice(2);
|
||||||
if (argv.length !== 1) {
|
if (argv.length !== 1) {
|
||||||
throw new Error('Expect WORKSPACE to be first parameter');
|
throw new Error('Expect WORKSPACE to be first parameter');
|
||||||
}
|
}
|
||||||
const workspace = argv[0];
|
const workspace = argv[0];
|
||||||
const content = fs.readFileSync(workspace, 'utf-8');
|
let content = fs.readFileSync(workspace, 'utf-8');
|
||||||
const regex = /ANGULAR_VERSION.*\nhttp_archive\((.*\n){4}\)/;
|
content = replaceAngular(content);
|
||||||
if (!regex.test(content)) {
|
content = replaceNpm(content);
|
||||||
throw new Error("Failed to find http_archive rule for Angular in WORKSPACE");
|
fs.writeFileSync(workspace, content);
|
||||||
}
|
|
||||||
const newContent = content.replace(regex, `
|
|
||||||
local_repository(
|
|
||||||
name = "angular",
|
|
||||||
path = "../../..",
|
|
||||||
)`);
|
|
||||||
fs.writeFileSync(workspace, newContent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main(process.argv)
|
main(process.argv)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user