Skip to content

Commit eef5a61

Browse files
committed
fix: handle empty and malformed --features values
Filter empty strings from parsed features so that --features "", --features "," and trailing commas don't produce confusing error messages with blank feature names. An effectively empty features list after filtering is treated as missing --features.
1 parent 72122c9 commit eef5a61

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

source/nonInteractive.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ function parseFeatures(featuresFlag: string | undefined): FeatureName[] {
3434
return []
3535
}
3636

37-
return featuresFlag.split(',').map((f) => f.trim()) as FeatureName[]
37+
return featuresFlag
38+
.split(',')
39+
.map((f) => f.trim())
40+
.filter((f) => f !== '') as FeatureName[]
3841
}
3942

4043
function validate(flags: {
@@ -72,6 +75,11 @@ function validate(flags: {
7275
}
7376

7477
const features = parseFeatures(flags.features)
78+
79+
if (features.length === 0) {
80+
fail('--mode custom requires --features. Use --info to see available features.')
81+
}
82+
7583
const invalidFeatures = features.filter((f) => !featureNames.includes(f))
7684

7785
if (invalidFeatures.length > 0) {

0 commit comments

Comments
 (0)