Skip to content

Commit

Permalink
fix(angular): strip trailing slash from directory nrwl#9263
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Mar 14, 2022
1 parent 0d6bdf5 commit 366f1ee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Expand Up @@ -34,7 +34,13 @@ export function normalizeOptions(

const name = names(options.name).fileName;
const projectDirectory = options.directory
? `${names(options.directory).fileName}/${name}`
? `${
names(
options.directory.endsWith('/')
? options.directory.slice(0, -1)
: options.directory
).fileName
}/${name}`
: name;

const { libsDir, npmScope, standaloneAsDefault } = getWorkspaceLayout(host);
Expand Down
13 changes: 13 additions & 0 deletions packages/angular/src/generators/library/library.spec.ts
Expand Up @@ -46,6 +46,19 @@ describe('lib', () => {
tree = createTreeWithEmptyWorkspace(2);
});

it('should run the library generator without erroring if the directory has a trailing slash', async () => {
// ACT
let error = null;
try {
await runLibraryGeneratorWithOpts({ directory: 'mylib/shared/' });
} catch (e) {
error = e;
} finally {
// ASSERT
expect(error).toBe(null);
}
});

it('should default to standalone project for first project', async () => {
await runLibraryGeneratorWithOpts();
const workspaceJsonEntry = readJson(tree, 'workspace.json').projects[
Expand Down

0 comments on commit 366f1ee

Please sign in to comment.