fix(proxy): handle end-of-options parsing

This commit is contained in:
Wooseong Kim
2026-04-20 14:27:09 +09:00
parent f4f33b0b5f
commit 2a80f7b1c1
2 changed files with 19 additions and 1 deletions
+7 -1
View File
@@ -22,9 +22,15 @@ function parseOptionValue(args: string[], key: string): string | undefined {
return withEquals ? withEquals.slice(prefix.length) : undefined;
}
function findPositionalArg(args: string[], optionsWithValues: string[] = []): string | undefined {
export function findPositionalArg(
args: string[],
optionsWithValues: string[] = []
): string | undefined {
for (let i = 0; i < args.length; i += 1) {
const arg = args[i];
if (arg === '--') {
return args[i + 1];
}
if (arg.startsWith('-')) {
if (optionsWithValues.includes(arg)) {
i += 1;
+12
View File
@@ -0,0 +1,12 @@
import { describe, expect, it } from 'bun:test';
import { findPositionalArg } from '../../../src/commands/proxy-command';
describe('findPositionalArg', () => {
it('skips option values before returning the first positional argument', () => {
expect(findPositionalArg(['--port', '3456', 'ccg'], ['--port'])).toBe('ccg');
});
it('treats arguments after -- as positional', () => {
expect(findPositionalArg(['--', '--port', '3456'], ['--port'])).toBe('--port');
});
});