fix(bazel): fix TS errors in the schematics/bazel-workspace
files (#27600)
Upgrading to the new `ts_library` rule uncovered TS errors in these files. This commit fixes the code to pass TS checking. PR Close #27600
This commit is contained in:
parent
30a3b49830
commit
3290fc3365
@ -48,7 +48,7 @@ function findVersion(projectName: string, packageName: string, host: Tree): stri
|
|||||||
*/
|
*/
|
||||||
export function clean(version: string): string|null {
|
export function clean(version: string): string|null {
|
||||||
const matches = version.match(/(\d+\.\d+\.\d+)/);
|
const matches = version.match(/(\d+\.\d+\.\d+)/);
|
||||||
return matches ? matches.pop() : null;
|
return matches && matches.pop() || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function(options: BazelWorkspaceOptions): Rule {
|
export default function(options: BazelWorkspaceOptions): Rule {
|
||||||
@ -72,12 +72,12 @@ export default function(options: BazelWorkspaceOptions): Rule {
|
|||||||
RxJs: findVersion(options.name, 'rxjs', host),
|
RxJs: findVersion(options.name, 'rxjs', host),
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const name of Object.keys(existingVersions)) {
|
Object.keys(existingVersions).forEach((name: 'Angular' | 'RxJs') => {
|
||||||
const version = existingVersions[name];
|
const version = existingVersions[name] as string;
|
||||||
if (version) {
|
if (version) {
|
||||||
context.logger.info(`Bazel will reuse existing version for ${name}: ${version}`);
|
context.logger.info(`Bazel will reuse existing version for ${name}: ${version}`);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
const workspaceVersions = {
|
const workspaceVersions = {
|
||||||
'ANGULAR_VERSION': existingVersions.Angular || clean(latestVersions.Angular),
|
'ANGULAR_VERSION': existingVersions.Angular || clean(latestVersions.Angular),
|
||||||
|
@ -64,7 +64,7 @@ describe('Bazel-workspace Schematic', () => {
|
|||||||
describe('clean', () => {
|
describe('clean', () => {
|
||||||
[['1.2.3', '1.2.3'], [' 1.2.3', '1.2.3'], ['1.2.3 ', '1.2.3'], ['~1.2.3', '1.2.3'],
|
[['1.2.3', '1.2.3'], [' 1.2.3', '1.2.3'], ['1.2.3 ', '1.2.3'], ['~1.2.3', '1.2.3'],
|
||||||
['^1.2.3', '1.2.3'], ['v1.2.3', '1.2.3'], ['1.2', null], ['a.b.c', null],
|
['^1.2.3', '1.2.3'], ['v1.2.3', '1.2.3'], ['1.2', null], ['a.b.c', null],
|
||||||
].forEach(([version, want]) => {
|
].forEach(([version, want]: [string, string]) => {
|
||||||
it(`should match ${version} with ${want}`, () => {
|
it(`should match ${version} with ${want}`, () => {
|
||||||
const got = clean(version);
|
const got = clean(version);
|
||||||
expect(got).toBe(want);
|
expect(got).toBe(want);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user