Skip to content

Commit

Permalink
fix(core): add unused options parameter
Browse files Browse the repository at this point in the history
Add an unused parameter to keep Nx from overwriting the dotnet client.
  • Loading branch information
Ben Callaghan committed May 19, 2021
1 parent 83caa85 commit c434d32
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions packages/core/src/generators/init/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,39 @@ describe('init generator', () => {
});

it('should create config', async () => {
await generator(appTree, dotnetClient);
await generator(appTree, null, dotnetClient);
const config = appTree.isFile(CONFIG_FILE_PATH);
expect(config).toBeTruthy();
});

it('should update gitignore', async () => {
appTree.write('.gitignore', '');
await generator(appTree, dotnetClient);
await generator(appTree, null, dotnetClient);
const gitignoreValue = appTree.read('.gitignore')?.toString();
expect(gitignoreValue).toBeTruthy();
});

it('should put dependency array inside config', async () => {
await generator(appTree, dotnetClient);
await generator(appTree, null, dotnetClient);
const config: NxDotnetConfig = readJson(appTree, CONFIG_FILE_PATH);
expect(config.nugetPackages).toBeDefined();
});

it('should create tool manifest', async () => {
const spy = spyOn(dotnetClient, 'new');
await generator(appTree, dotnetClient);
await generator(appTree, null, dotnetClient);
expect(spy).toHaveBeenCalledWith('tool-manifest');
});

it('should not create tool manifest if it exists', async () => {
appTree.write('.config/dotnet-tools.json', '');
const spy = spyOn(dotnetClient, 'new');
await generator(appTree, dotnetClient);
await generator(appTree, null, dotnetClient);
expect(spy).not.toHaveBeenCalled();
});

it('should add restore to prepare script', async () => {
await generator(appTree, dotnetClient);
await generator(appTree, null, dotnetClient);
const updated = readJson(appTree, 'package.json');
expect(updated.scripts.prepare).toBe('nx g @nx-dotnet/core:restore');
});
Expand All @@ -61,7 +61,7 @@ describe('init generator', () => {
scripts: { prepare: 'nx g @nx-dotnet/core:restore' },
};
writeJson(appTree, 'package.json', packageJson);
await generator(appTree, dotnetClient);
await generator(appTree, null, dotnetClient);
const updated = readJson(appTree, 'package.json');
expect(updated.scripts.prepare).toBe('nx g @nx-dotnet/core:restore');
});
Expand All @@ -71,7 +71,7 @@ describe('init generator', () => {
scripts: { prepare: 'npm run clean && npm run build' },
};
writeJson(appTree, 'package.json', packageJson);
await generator(appTree, dotnetClient);
await generator(appTree, null, dotnetClient);
const updated = readJson(appTree, 'package.json');
expect(updated.scripts.prepare).toBe(
'npm run clean && npm run build && nx g @nx-dotnet/core:restore',
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/generators/init/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
readJson,
readWorkspaceConfiguration,
Tree,
updateWorkspaceConfiguration,
WorkspaceConfiguration,
writeJson,
} from '@nrwl/devkit';
Expand All @@ -13,6 +12,7 @@ import { CONFIG_FILE_PATH, NxDotnetConfig } from '@nx-dotnet/utils';

export default async function (
host: Tree,
_: null, // Nx will populate this with options, which are currently unused.
dotnetClient = new DotNetClient(dotnetFactory()),
) {
const initialized = host.isFile(CONFIG_FILE_PATH);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/generators/utils/generate-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export async function GenerateProject(
dotnetClient: DotNetClient,
projectType: ProjectType,
) {
await initSchematic(host, dotnetClient);
await initSchematic(host, null, dotnetClient);

options.testTemplate = options.testTemplate ?? 'none';

Expand Down

0 comments on commit c434d32

Please sign in to comment.