Skip to content

Commit f070c20

Browse files
devversionamysorto
authored andcommitted
build: fix approve-api golden script
The API goldens have been flattened as part of 766b07e, but the script for updating goldens has not been updated. This commit fixes the script so that it respects the new file location of goldens.
1 parent d84e2bc commit f070c20

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

scripts/approve-api-golden.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,29 @@
33
const shelljs = require('shelljs');
44
const chalk = require('chalk');
55
const path = require('path');
6-
const packageName = process.argv[2];
6+
const searchPackageName = process.argv[2];
77
const {guessPackageName} = require('./util');
88

9-
if (!packageName) {
9+
if (!searchPackageName) {
1010
console.error(chalk.red('No package name has been passed in for API golden approval.'));
1111
process.exit(1);
1212
}
1313

1414
const projectDir = path.join(__dirname, '../');
15-
const packageNameGuess = guessPackageName(packageName, path.join(projectDir, 'src'));
15+
const packageNameGuess = guessPackageName(searchPackageName, path.join(projectDir, 'src'));
1616

1717
if (!packageNameGuess.result) {
1818
console.error(chalk.red(`Could not find package for API golden approval called ` +
19-
`${chalk.yellow(packageName)}. Looked in packages: \n${packageNameGuess.attempts.join('\n')}`));
19+
`${chalk.yellow(searchPackageName)}. Looked in packages:\n` +
20+
`${packageNameGuess.attempts.join('\n')}`));
2021
process.exit(1);
2122
}
2223

24+
const [packageName, ...entryPointTail] = packageNameGuess.result.split('/');
25+
const apiGoldenTargetName =
26+
`//tools/public_api_guard:${packageName}/${entryPointTail.join('-')}.md_api.accept`;
27+
2328
// ShellJS should exit if any command fails.
2429
shelljs.set('-e');
2530
shelljs.cd(projectDir);
26-
shelljs.exec(`yarn bazel run //tools/public_api_guard:${packageNameGuess.result}.d.ts_api.accept`);
31+
shelljs.exec(`yarn bazel run ${apiGoldenTargetName}`);

0 commit comments

Comments
 (0)