2019-01-10 19:04:05 -05:00
|
|
|
// TODO(kyliau): This file should be removed when we use Angular npm distro from
|
|
|
|
// Bazel projects.
|
|
|
|
|
|
|
|
const fs = require('fs');
|
|
|
|
|
2019-02-04 20:45:02 -05:00
|
|
|
function replaceAngular(content) {
|
2019-01-10 19:04:05 -05:00
|
|
|
const regex = /ANGULAR_VERSION.*\nhttp_archive\((.*\n){4}\)/;
|
|
|
|
if (!regex.test(content)) {
|
2019-02-12 20:44:54 -05:00
|
|
|
throw new Error('Failed to find http_archive rule for Angular in WORKSPACE');
|
2019-01-10 19:04:05 -05:00
|
|
|
}
|
2019-02-04 20:45:02 -05:00
|
|
|
return content.replace(regex, `
|
2019-01-10 19:04:05 -05:00
|
|
|
local_repository(
|
|
|
|
name = "angular",
|
|
|
|
path = "../../..",
|
|
|
|
)`);
|
2019-02-04 20:45:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function main(argv) {
|
|
|
|
argv = argv.slice(2);
|
|
|
|
if (argv.length !== 1) {
|
|
|
|
throw new Error('Expect WORKSPACE to be first parameter');
|
|
|
|
}
|
|
|
|
const workspace = argv[0];
|
|
|
|
let content = fs.readFileSync(workspace, 'utf-8');
|
|
|
|
content = replaceAngular(content);
|
|
|
|
fs.writeFileSync(workspace, content);
|
2019-01-10 19:04:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
main(process.argv)
|