Skip to content

Commit 0e3862c

Browse files
committed
fix: support comma-separated filePath for upload_file
1 parent 9dcc546 commit 0e3862c

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/bin/chrome-devtools-cli-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ export const commands: Commands = {
711711
name: 'filePath',
712712
type: 'string',
713713
description:
714-
'The local path of a file to upload. Use filePaths for multiple files.',
714+
'The local path of a file to upload. For multiple files, pass a comma-separated list, or use filePaths.',
715715
required: false,
716716
},
717717
filePaths: {

src/bin/cliDefinitions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ export const commands: Commands = {
692692
name: 'filePath',
693693
type: 'string',
694694
description:
695-
'The local path of a file to upload. Use filePaths for multiple files.',
695+
'The local path of a file to upload. For multiple files, pass a comma-separated list, or use filePaths.',
696696
required: false,
697697
},
698698
filePaths: {

src/tools/input.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,19 @@ export const uploadFile = definePageTool({
373373
},
374374
handler: async (request, response) => {
375375
const {uid} = request.params;
376-
const filePaths =
377-
request.params.filePaths ??
378-
(request.params.filePath ? [request.params.filePath] : []);
376+
377+
const filePathsFromFilePath = request.params.filePath
378+
? request.params.filePath
379+
.split(',')
380+
.map((p) => p.trim())
381+
.filter(Boolean)
382+
: [];
383+
384+
const filePaths = [
385+
...(request.params.filePaths ?? []),
386+
...filePathsFromFilePath,
387+
];
388+
379389
if (!filePaths.length) {
380390
throw new Error('Provide filePath or filePaths to upload.');
381391
}

0 commit comments

Comments
 (0)