Skip to content

Commit 4da9400

Browse files
committed
fix(@angular/build): prioritize string type for runnerConfig schema
Reorders the `type` union in the `runnerConfig` option's schema to prioritize `string` over `boolean`. This change provides a stronger hint to the CLI's argument parser, ensuring that when a value is provided for the option (e.g., a file path), it is unambiguously treated as a string. This improves the robustness of the parsing logic for this union-type option while preserving the functionality of its boolean flag forms.
1 parent f074f13 commit 4da9400

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/angular/build/src/builders/unit-test/options.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ export async function normalizeOptions(
127127
dumpVirtualFiles: options.dumpVirtualFiles,
128128
listTests: options.listTests,
129129
runnerConfig:
130-
typeof runnerConfig === 'string' ? path.resolve(workspaceRoot, runnerConfig) : runnerConfig,
130+
typeof runnerConfig === 'string'
131+
? runnerConfig.length === 0
132+
? true
133+
: path.resolve(workspaceRoot, runnerConfig)
134+
: runnerConfig,
131135
};
132136
}
133137

packages/angular/build/src/builders/unit-test/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"enum": ["karma", "vitest"]
2121
},
2222
"runnerConfig": {
23-
"type": ["boolean", "string"],
23+
"type": ["string", "boolean"],
2424
"description": "Specifies the configuration file for the selected test runner. If a string is provided, it will be used as the path to the configuration file. If `true`, the builder will search for a default configuration file (e.g., `vitest.config.ts` or `karma.conf.js`). If `false`, no external configuration file will be used.\\nFor Vitest, this enables advanced options and the use of custom plugins. Please note that while the file is loaded, the Angular team does not provide direct support for its specific contents or any third-party plugins used within it.",
2525
"default": false
2626
},

0 commit comments

Comments
 (0)