diff --git a/packages/angular/src/generators/library/lib/normalize-options.ts b/packages/angular/src/generators/library/lib/normalize-options.ts index cbb5db8792346..d498f87696781 100644 --- a/packages/angular/src/generators/library/lib/normalize-options.ts +++ b/packages/angular/src/generators/library/lib/normalize-options.ts @@ -34,7 +34,7 @@ export function normalizeOptions( const name = names(options.name).fileName; const projectDirectory = options.directory - ? `${names(options.directory).fileName}/${name}` + ? `${names(options.directory).fileName}/${name}`.replace(/\/+/g, '/') : name; const { libsDir, npmScope, standaloneAsDefault } = getWorkspaceLayout(host); diff --git a/packages/angular/src/generators/library/library.spec.ts b/packages/angular/src/generators/library/library.spec.ts index 2e08cd3088d20..e0ef3e38f6837 100644 --- a/packages/angular/src/generators/library/library.spec.ts +++ b/packages/angular/src/generators/library/library.spec.ts @@ -46,6 +46,13 @@ describe('lib', () => { tree = createTreeWithEmptyWorkspace(2); }); + it('should run the library generator without erroring if the directory has a trailing slash', async () => { + // ACT & ASSERT + await expect( + runLibraryGeneratorWithOpts({ directory: 'mylib/shared/' }) + ).resolves.not.toThrow(); + }); + it('should default to standalone project for first project', async () => { await runLibraryGeneratorWithOpts(); const workspaceJsonEntry = readJson(tree, 'workspace.json').projects[