fix(angular): strip trailing slash from directory #9263 (#9314)

This commit is contained in:
Colum Ferry 2022-03-15 09:38:32 +00:00 committed by GitHub
parent 53a0528d7a
commit 3c39c311f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -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);

View File

@ -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[