Skip to content

Commit

Permalink
Add --filter option to API docs script
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Apr 7, 2020
1 parent eacdbcd commit ce7fdee
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/dev/run_check_published_api_changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ interface Options {
accept: boolean;
docs: boolean;
help: boolean;
filter: string;
}

async function run(
Expand Down Expand Up @@ -205,6 +206,7 @@ async function run(
const extraFlags: string[] = [];
const opts = (getopts(process.argv.slice(2), {
boolean: ['accept', 'docs', 'help'],
string: ['filter'],
default: {
project: undefined,
},
Expand All @@ -222,6 +224,8 @@ async function run(
opts.help = true;
}

const folders = ['core/public', 'core/server', 'plugins/data/server', 'plugins/data/public'];

if (opts.help) {
process.stdout.write(
dedent(chalk`
Expand All @@ -240,9 +244,13 @@ async function run(
{dim # Checks for and automatically accepts and updates documentation for any changes to the Kibana Core API}
{dim $} node scripts/check_published_api_changes --accept
{dim # Only checks the core/public directory}
{dim $} node scripts/check_published_api_changes --filter=core/public
Options:
--accept {dim Accepts all changes by updating the API Review files and documentation}
--docs {dim Updates the Core API documentation}
--only {dim RegExp that folder names must match, folders: [${folders.join(', ')}]}
--help {dim Show this message}
`)
);
Expand All @@ -258,9 +266,11 @@ async function run(
return false;
}

const folders = ['core/public', 'core/server', 'plugins/data/server', 'plugins/data/public'];

const results = await Promise.all(folders.map(folder => run(folder, { log, opts })));
const results = await Promise.all(
folders
.filter(folder => (opts.filter.length ? folder.match(opts.filter) : true))
.map(folder => run(folder, { log, opts }))
);

if (results.find(r => r === false) !== undefined) {
process.exitCode = 1;
Expand Down

0 comments on commit ce7fdee

Please sign in to comment.