Skip to content

Commit cc34435

Browse files
committed
fix: deduplicate feature names in parseFeatures
--features demo,demo would propagate duplicates into operations args and JSON output. Now uses a Set to preserve order while filtering dupes.
1 parent 5322d74 commit cc34435

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

source/__tests__/nonInteractive.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,13 @@ describe('nonInteractive — custom mode execution', () => {
261261
const output = getLastJsonOutput()
262262
expect(output.features).toEqual(['demo'])
263263
})
264+
265+
it('deduplicates feature names', async () => {
266+
await runNonInteractive({ name: 'my_app', mode: 'custom', features: 'demo,demo,subgraph,demo' })
267+
268+
const output = getLastJsonOutput()
269+
expect(output.features).toEqual(['demo', 'subgraph'])
270+
})
264271
})
265272

266273
describe('nonInteractive — error handling during execution', () => {

source/nonInteractive.ts

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

37+
const seen = new Set<string>()
38+
3739
return featuresFlag
3840
.split(',')
3941
.map((f) => f.trim())
40-
.filter((f) => f !== '') as FeatureName[]
42+
.filter((f) => {
43+
if (f === '' || seen.has(f)) {
44+
return false
45+
}
46+
47+
seen.add(f)
48+
return true
49+
}) as FeatureName[]
4150
}
4251

4352
function validate(flags: {

0 commit comments

Comments
 (0)