Skip to content

Commit eab2d48

Browse files
authored
fix(dotnet): correct flag passed to client to verify no changes (#786)
1 parent e5b7deb commit eab2d48

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

packages/dotnet/src/lib/core/dotnet.client.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,38 @@ ASP.NET Core gRPC Service grpc [C#]
285285
`);
286286
});
287287

288+
it('should call subcommands properly when on .NET 6 and passing --fixWhitespace and --check', () => {
289+
const dotnetClient = new DotNetClient(mockDotnetFactory('6.0.0'));
290+
const spy = jest
291+
.spyOn(dotnetClient, 'logAndExecute')
292+
.mockImplementation(() => ({}));
293+
dotnetClient.format('my-project', {
294+
fixWhitespace: false,
295+
check: true,
296+
});
297+
expect(spy).toHaveBeenCalledTimes(2);
298+
expect(spy.mock.calls).toMatchInlineSnapshot(`
299+
[
300+
[
301+
[
302+
"format",
303+
"style",
304+
"my-project",
305+
"--verify-no-changes",
306+
],
307+
],
308+
[
309+
[
310+
"format",
311+
"analyzers",
312+
"my-project",
313+
"--verify-no-changes",
314+
],
315+
],
316+
]
317+
`);
318+
});
319+
288320
it('should call subcommands properly when on .NET 6 and passing --fixAnalyzers severity', () => {
289321
const dotnetClient = new DotNetClient(mockDotnetFactory('6.0.0'));
290322
const spy = jest

packages/dotnet/src/lib/core/dotnet.client.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,10 @@ export class DotNetClient {
215215
const subcommandParameterObject = {
216216
...parameters,
217217
};
218-
delete subcommandParameterObject.fixWhitespace;
219218
subcommandParams.push(
220-
...getSpawnParameterArray(subcommandParameterObject),
219+
...getSpawnParameterArray(
220+
swapKeysUsingMap(subcommandParameterObject, formatKeyMap),
221+
),
221222
);
222223
this.logAndExecute(subcommandParams);
223224
}
@@ -231,9 +232,10 @@ export class DotNetClient {
231232
if (typeof style === 'string') {
232233
subcommandParameterObject.severity = style;
233234
}
234-
delete subcommandParameterObject.fixStyle;
235235
subcommandParams.push(
236-
...getSpawnParameterArray(subcommandParameterObject),
236+
...getSpawnParameterArray(
237+
swapKeysUsingMap(subcommandParameterObject, formatKeyMap),
238+
),
237239
);
238240
this.logAndExecute(subcommandParams);
239241
}
@@ -247,17 +249,19 @@ export class DotNetClient {
247249
if (typeof analyzers === 'string') {
248250
subcommandParameterObject.severity = analyzers;
249251
}
250-
delete subcommandParameterObject.fixAnalyzers;
251252
subcommandParams.push(
252-
...getSpawnParameterArray(subcommandParameterObject),
253+
...getSpawnParameterArray(
254+
swapKeysUsingMap(subcommandParameterObject, formatKeyMap),
255+
),
253256
);
254257
this.logAndExecute(subcommandParams);
255258
}
256259
} else {
257260
params.push(project);
258261
if (parameters) {
259-
parameters = swapKeysUsingMap(parameters, formatKeyMap);
260-
params.push(...getSpawnParameterArray(parameters));
262+
params.push(
263+
...getSpawnParameterArray(swapKeysUsingMap(parameters, formatKeyMap)),
264+
);
261265
}
262266
return this.logAndExecute(params);
263267
}

0 commit comments

Comments
 (0)