|
3 | 3 | const shelljs = require('shelljs');
|
4 | 4 | const chalk = require('chalk');
|
5 | 5 | const path = require('path');
|
6 |
| -const packageName = process.argv[2]; |
| 6 | +const searchPackageName = process.argv[2]; |
7 | 7 | const {guessPackageName} = require('./util');
|
8 | 8 |
|
9 |
| -if (!packageName) { |
| 9 | +if (!searchPackageName) { |
10 | 10 | console.error(chalk.red('No package name has been passed in for API golden approval.'));
|
11 | 11 | process.exit(1);
|
12 | 12 | }
|
13 | 13 |
|
14 | 14 | const projectDir = path.join(__dirname, '../');
|
15 |
| -const packageNameGuess = guessPackageName(packageName, path.join(projectDir, 'src')); |
| 15 | +const packageNameGuess = guessPackageName(searchPackageName, path.join(projectDir, 'src')); |
16 | 16 |
|
17 | 17 | if (!packageNameGuess.result) {
|
18 | 18 | 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')}`)); |
20 | 21 | process.exit(1);
|
21 | 22 | }
|
22 | 23 |
|
| 24 | +const [packageName, ...entryPointTail] = packageNameGuess.result.split('/'); |
| 25 | +const apiGoldenTargetName = |
| 26 | + `//tools/public_api_guard:${packageName}/${entryPointTail.join('-')}.md_api.accept`; |
| 27 | + |
23 | 28 | // ShellJS should exit if any command fails.
|
24 | 29 | shelljs.set('-e');
|
25 | 30 | 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