|
3 | 3 | const shelljs = require('shelljs');
|
4 | 4 | const chalk = require('chalk');
|
5 | 5 | const path = require('path');
|
6 |
| -const searchPackageName = process.argv[2]; |
7 | 6 | const {guessPackageName} = require('./util');
|
8 |
| - |
9 |
| -if (!searchPackageName) { |
10 |
| - console.error(chalk.red('No package name has been passed in for API golden approval.')); |
11 |
| - process.exit(1); |
12 |
| -} |
13 |
| - |
14 | 7 | const projectDir = path.join(__dirname, '../');
|
15 |
| -const packageNameGuess = guessPackageName(searchPackageName, path.join(projectDir, 'src')); |
16 | 8 |
|
17 |
| -if (!packageNameGuess.result) { |
18 |
| - console.error( |
19 |
| - chalk.red( |
20 |
| - `Could not find package for API golden approval called ` + |
21 |
| - `${chalk.yellow(searchPackageName)}. Looked in packages:\n` + |
22 |
| - `${packageNameGuess.attempts.join('\n')}`, |
23 |
| - ), |
24 |
| - ); |
| 9 | +if (process.argv.length < 3) { |
| 10 | + console.error(chalk.red('No package name has been passed in for API golden approval.')); |
25 | 11 | process.exit(1);
|
26 | 12 | }
|
27 | 13 |
|
28 |
| -const [packageName, ...entryPointTail] = packageNameGuess.result.split('/'); |
29 |
| -const suffix = entryPointTail.length ? entryPointTail.join('-') : packageName; |
30 |
| -const apiGoldenTargetName = `//tools/public_api_guard:${packageName}/${suffix}.md_api.accept`; |
31 |
| - |
32 | 14 | // ShellJS should exit if any command fails.
|
33 | 15 | shelljs.set('-e');
|
34 | 16 | shelljs.cd(projectDir);
|
35 |
| -shelljs.touch(path.join(projectDir, `tools/public_api_guard/${packageName}/${suffix}.md`)); |
36 |
| -shelljs.exec(`yarn bazel run ${apiGoldenTargetName}`); |
| 17 | + |
| 18 | +for (const searchPackageName of process.argv.slice(2)) { |
| 19 | + const packageNameGuess = guessPackageName(searchPackageName, path.join(projectDir, 'src')); |
| 20 | + |
| 21 | + if (!packageNameGuess.result) { |
| 22 | + console.error( |
| 23 | + chalk.red( |
| 24 | + `Could not find package for API golden approval called ` + |
| 25 | + `${chalk.yellow(searchPackageName)}. Looked in packages:\n` + |
| 26 | + `${packageNameGuess.attempts.join('\n')}`, |
| 27 | + ), |
| 28 | + ); |
| 29 | + process.exit(1); |
| 30 | + } |
| 31 | + |
| 32 | + const [packageName, ...entryPointTail] = packageNameGuess.result.split('/'); |
| 33 | + const suffix = entryPointTail.length ? entryPointTail.join('-') : packageName; |
| 34 | + const apiGoldenTargetName = `//tools/public_api_guard:${packageName}/${suffix}.md_api.accept`; |
| 35 | + |
| 36 | + shelljs.touch(path.join(projectDir, `tools/public_api_guard/${packageName}/${suffix}.md`)); |
| 37 | + shelljs.exec(`yarn bazel run ${apiGoldenTargetName}`); |
| 38 | +} |
0 commit comments