Skip to content

Commit

Permalink
fix(dotnet): correct flag passed to client to verify no changes (#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
EchelonFour authored Oct 24, 2023
1 parent e5b7deb commit eab2d48
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
32 changes: 32 additions & 0 deletions packages/dotnet/src/lib/core/dotnet.client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,38 @@ ASP.NET Core gRPC Service grpc [C#]
`);
});

it('should call subcommands properly when on .NET 6 and passing --fixWhitespace and --check', () => {
const dotnetClient = new DotNetClient(mockDotnetFactory('6.0.0'));
const spy = jest
.spyOn(dotnetClient, 'logAndExecute')
.mockImplementation(() => ({}));
dotnetClient.format('my-project', {
fixWhitespace: false,
check: true,
});
expect(spy).toHaveBeenCalledTimes(2);
expect(spy.mock.calls).toMatchInlineSnapshot(`
[
[
[
"format",
"style",
"my-project",
"--verify-no-changes",
],
],
[
[
"format",
"analyzers",
"my-project",
"--verify-no-changes",
],
],
]
`);
});

it('should call subcommands properly when on .NET 6 and passing --fixAnalyzers severity', () => {
const dotnetClient = new DotNetClient(mockDotnetFactory('6.0.0'));
const spy = jest
Expand Down
20 changes: 12 additions & 8 deletions packages/dotnet/src/lib/core/dotnet.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,10 @@ export class DotNetClient {
const subcommandParameterObject = {
...parameters,
};
delete subcommandParameterObject.fixWhitespace;
subcommandParams.push(
...getSpawnParameterArray(subcommandParameterObject),
...getSpawnParameterArray(
swapKeysUsingMap(subcommandParameterObject, formatKeyMap),
),
);
this.logAndExecute(subcommandParams);
}
Expand All @@ -231,9 +232,10 @@ export class DotNetClient {
if (typeof style === 'string') {
subcommandParameterObject.severity = style;
}
delete subcommandParameterObject.fixStyle;
subcommandParams.push(
...getSpawnParameterArray(subcommandParameterObject),
...getSpawnParameterArray(
swapKeysUsingMap(subcommandParameterObject, formatKeyMap),
),
);
this.logAndExecute(subcommandParams);
}
Expand All @@ -247,17 +249,19 @@ export class DotNetClient {
if (typeof analyzers === 'string') {
subcommandParameterObject.severity = analyzers;
}
delete subcommandParameterObject.fixAnalyzers;
subcommandParams.push(
...getSpawnParameterArray(subcommandParameterObject),
...getSpawnParameterArray(
swapKeysUsingMap(subcommandParameterObject, formatKeyMap),
),
);
this.logAndExecute(subcommandParams);
}
} else {
params.push(project);
if (parameters) {
parameters = swapKeysUsingMap(parameters, formatKeyMap);
params.push(...getSpawnParameterArray(parameters));
params.push(
...getSpawnParameterArray(swapKeysUsingMap(parameters, formatKeyMap)),
);
}
return this.logAndExecute(params);
}
Expand Down

0 comments on commit eab2d48

Please sign in to comment.