Skip to content

Commit 94029e6

Browse files
committed
puppeteer server: deduplication of launch option args
1 parent 4f93f82 commit 94029e6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/puppeteer/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,13 @@ function deepMerge(target: any, source: any): any {
186186
const targetVal = target[key];
187187
const sourceVal = source[key];
188188
if (Array.isArray(targetVal) && Array.isArray(sourceVal)) {
189-
output[key] = [...targetVal, ...sourceVal];
189+
// Deduplicate args/ignoreDefaultArgs, prefer source values
190+
output[key] = [...new Set([
191+
...(key === 'args' || key === 'ignoreDefaultArgs' ?
192+
targetVal.filter((arg: string) => !sourceVal.some((launchArg: string) => arg.startsWith('--') && launchArg.startsWith(arg.split('=')[0]))) :
193+
targetVal),
194+
...sourceVal
195+
])];
190196
} else if (sourceVal instanceof Object && key in target) {
191197
output[key] = deepMerge(targetVal, sourceVal);
192198
} else {

0 commit comments

Comments
 (0)