Skip to content

Commit 96501f4

Browse files
OrKoNdependabot[bot]Piotr Paulski
committed
chore(deps-dev): bump chrome-devtools-frontend from 1.0.1613625 to 1.0.1616061 (#1952)
Closes #1908 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Piotr Paulski <piotrpaulski@chromium.org>
1 parent 3c32949 commit 96501f4

8 files changed

Lines changed: 18 additions & 27 deletions

File tree

src/McpContext.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ export class McpContext implements Context {
165165
this.#roots = roots;
166166
}
167167

168-
validatePath(filePath: string): void {
168+
validatePath(filePath?: string): void {
169+
if (filePath === undefined) {
170+
return;
171+
}
169172
const roots = this.roots();
170173
if (roots === undefined) {
171174
return;
@@ -676,7 +679,11 @@ export class McpContext implements Context {
676679
): Promise<{filepath: string}> {
677680
const filepath = await getTempFilePath(filename);
678681
this.validatePath(filepath);
679-
await fs.writeFile(filepath, data);
682+
try {
683+
await fs.writeFile(filepath, data);
684+
} catch (err) {
685+
throw new Error('Could not save a file', {cause: err});
686+
}
680687
return {filepath};
681688
}
682689

src/tools/ToolDefinition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export type SupportedExtensions =
170170
* Only add methods used by tools/*.
171171
*/
172172
export type Context = Readonly<{
173-
validatePath(filePath: string): void;
173+
validatePath(filePath?: string): void;
174174
isRunningPerformanceTrace(): boolean;
175175
setIsRunningPerformanceTrace(x: boolean): void;
176176
isCruxEnabled(): boolean;

src/tools/lighthouse.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ export const lighthouseAudit = definePageTool({
5353
outputDirPath,
5454
} = request.params;
5555

56-
if (outputDirPath) {
57-
context.validatePath(outputDirPath);
58-
}
56+
context.validatePath(outputDirPath);
5957

6058
const flags: Flags = {
6159
onlyCategories: categories,

src/tools/network.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,8 @@ export const getNetworkRequest = definePageTool({
114114
),
115115
},
116116
handler: async (request, response, context) => {
117-
if (request.params.requestFilePath) {
118-
context.validatePath(request.params.requestFilePath);
119-
}
120-
if (request.params.responseFilePath) {
121-
context.validatePath(request.params.responseFilePath);
122-
}
117+
context.validatePath(request.params.requestFilePath);
118+
context.validatePath(request.params.responseFilePath);
123119
if (request.params.reqid) {
124120
response.attachNetworkRequest(request.params.reqid, {
125121
requestFilePath: request.params.requestFilePath,

src/tools/performance.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ export const startTrace = definePageTool({
4949
filePath: filePathSchema,
5050
},
5151
handler: async (request, response, context) => {
52-
if (request.params.filePath) {
53-
context.validatePath(request.params.filePath);
54-
}
52+
context.validatePath(request.params.filePath);
5553
if (context.isRunningPerformanceTrace()) {
5654
response.appendResponseLine(
5755
'Error: a performance trace is already running. Use performance_stop_trace to stop it. Only one trace can be running at any given time.',
@@ -129,9 +127,7 @@ export const stopTrace = definePageTool({
129127
filePath: filePathSchema,
130128
},
131129
handler: async (request, response, context) => {
132-
if (request.params.filePath) {
133-
context.validatePath(request.params.filePath);
134-
}
130+
context.validatePath(request.params.filePath);
135131
if (!context.isRunningPerformanceTrace()) {
136132
return;
137133
}

src/tools/screencast.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ export const startScreencast = definePageTool(args => ({
4040
),
4141
},
4242
handler: async (request, response, context) => {
43-
if (request.params.filePath) {
44-
context.validatePath(request.params.filePath);
45-
}
43+
context.validatePath(request.params.filePath);
4644
if (context.getScreenRecorder() !== null) {
4745
response.appendResponseLine(
4846
'Error: a screencast recording is already in progress. Use screencast_stop to stop it before starting a new one.',

src/tools/screenshot.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ export const screenshot = definePageTool({
5151
),
5252
},
5353
handler: async (request, response, context) => {
54-
if (request.params.filePath) {
55-
context.validatePath(request.params.filePath);
56-
}
54+
context.validatePath(request.params.filePath);
5755
if (request.params.uid && request.params.fullPage) {
5856
throw new Error('Providing both "uid" and "fullPage" is not allowed.');
5957
}

src/tools/snapshot.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ in the DevTools Elements panel (if any).`,
3434
),
3535
},
3636
handler: async (request, response, context) => {
37-
if (request.params.filePath) {
38-
context.validatePath(request.params.filePath);
39-
}
37+
context.validatePath(request.params.filePath);
4038
response.includeSnapshot({
4139
verbose: request.params.verbose ?? false,
4240
filePath: request.params.filePath,

0 commit comments

Comments
 (0)