mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-09-29 12:07:05 -07:00
fix: glue --flag=value instead of --flag value, avoiding argv ambiguity
Real bug caught by live CI (not the release-timing gap, which was separately expected and has since resolved): "--flag value" as two argv tokens is ambiguous when value itself starts with "-" - e.g. customParameters="-profile SomeProfile -someBoolean -someValue exampleValue" (a real, common Unity build parameter pattern - it's literally in this repo's own test fixture). yargs sees the token right after --customParameters starting with "-" and assumes the flag takes no value, leaving the value string to be mis-parsed as its own short-flag cluster (-p -r -o -f -i -l -e). Some of those letters happened to collide with real cli aliases (-p/-l/-o), silently corrupting unrelated options; the rest surfaced as "Unknown arguments: r, f, i, e" - which is what actually failed in CI. Verified against the real cli binary locally (bun run src/index.ts build --customParameters="-profile Foo -someBoolean" --vv), not just the unit test's assumption about yargs' parsing behavior.
This commit is contained in:
+8
-2
@@ -80,7 +80,7 @@ function buildCliArgs({ getInput }) {
|
||||
if (!targetPlatform) {
|
||||
throw new Error('targetPlatform is required.');
|
||||
}
|
||||
args.push('--targetPlatform', targetPlatform);
|
||||
args.push(`--targetPlatform=${targetPlatform}`);
|
||||
const providerStrategy = getInput('providerStrategy') || 'local';
|
||||
if (providerStrategy !== 'local') {
|
||||
throw new Error(`Provider strategy "${providerStrategy}" is not supported by this thin wrapper. ` +
|
||||
@@ -89,8 +89,14 @@ function buildCliArgs({ getInput }) {
|
||||
}
|
||||
for (const [input, flag] of STRING_FLAGS) {
|
||||
const value = getInput(input);
|
||||
// "--flag value" as two argv tokens is ambiguous when value itself
|
||||
// starts with "-" (e.g. customParameters="-profile Foo -someBoolean"):
|
||||
// yargs sees the next token starting with "-" and assumes the flag
|
||||
// takes no value, leaving the value string to be mis-parsed as its own
|
||||
// (partly alias-colliding) short-flag cluster. "--flag=value" glues
|
||||
// them into one token, which is unambiguous.
|
||||
if (value)
|
||||
args.push(`--${flag}`, value);
|
||||
args.push(`--${flag}=${value}`);
|
||||
}
|
||||
for (const [input, flag] of BOOLEAN_FLAGS) {
|
||||
const value = getInput(input);
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user