Skip to content

Commit af49c7c

Browse files
crisbetoannieyw
authored andcommitted
build: check MDC testing exports
Updates the MDC exports script to also check the `/testing` packages.
1 parent 154ef43 commit af49c7c

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

scripts/check-mdc-exports.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ readdirSync(join(__dirname, '../src/material'), {withFileTypes: true})
1616
.filter(name => !config.skippedPackages.includes(`mdc-${name}`))
1717
.filter(hasCorrespondingMdcPackage)
1818
.forEach(name => {
19-
const missingSymbols = getMissingSymbols(name, config.skippedExports[`mdc-${name}`] || []);
19+
checkPackage(name);
2020

21-
if (missingSymbols.length) {
22-
console.log(chalk.redBright(`\nMissing symbols from mdc-${name}:`));
23-
console.log(missingSymbols.join('\n'));
24-
hasFailed = true;
21+
const testingName = name + '/testing';
22+
if (hasTestingPackage(name) && hasCorrespondingMdcPackage(testingName)) {
23+
checkPackage(testingName);
2524
}
2625
});
2726

@@ -39,6 +38,17 @@ if (hasFailed) {
3938
process.exit(0);
4039
}
4140

41+
/** Checks whether the public API of a package matches up with its MDC counterpart. */
42+
function checkPackage(name: string) {
43+
const missingSymbols = getMissingSymbols(name, config.skippedExports[`mdc-${name}`] || []);
44+
45+
if (missingSymbols.length) {
46+
console.log(chalk.redBright(`\nMissing symbols from mdc-${name}:`));
47+
console.log(missingSymbols.join('\n'));
48+
hasFailed = true;
49+
}
50+
}
51+
4252
/**
4353
* Gets the names of symbols that are present in a Material package,
4454
* but not its MDC counterpart.
@@ -90,3 +100,8 @@ function getExports(name: string): string[] {
90100
function hasCorrespondingMdcPackage(name: string): boolean {
91101
return existsSync(join(__dirname, '../src/material-experimental', 'mdc-' + name));
92102
}
103+
104+
/** Checks whether a particular Material package has a testing sub-package. */
105+
function hasTestingPackage(name: string): boolean {
106+
return existsSync(join(__dirname, '../src/material', name, 'testing'));
107+
}

0 commit comments

Comments
 (0)