cli: fix for repo test arg trimming removing too many args

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-10-07 17:23:15 +02:00
parent a99a28570b
commit b3b4825162
+3 -3
View File
@@ -112,7 +112,7 @@ export function createFlagFinder(args: string[]) {
};
}
function removeOptionArg(args: string[], option: string) {
function removeOptionArg(args: string[], option: string, size: number = 2) {
let changed = false;
do {
changed = false;
@@ -120,7 +120,7 @@ function removeOptionArg(args: string[], option: string) {
const index = args.indexOf(option);
if (index >= 0) {
changed = true;
args.splice(index, 2);
args.splice(index, size);
}
const indexEq = args.findIndex(arg => arg.startsWith(`${option}=`));
if (indexEq >= 0) {
@@ -243,7 +243,7 @@ export async function command(opts: OptionValues, cmd: Command): Promise<void> {
// This code path is enabled by the --successCache flag, which is specific to
// the `repo test` command in the Backstage CLI.
if (opts.successCache) {
removeOptionArg(args, '--successCache');
removeOptionArg(args, '--successCache', 1);
removeOptionArg(args, '--successCacheDir');
const cacheDir = resolvePath(