Skip to content

Commit

Permalink
fix(misc): ensure provided import path has precedence over scoped pro…
Browse files Browse the repository at this point in the history
…ject name
  • Loading branch information
leosvelperez committed Aug 10, 2023
1 parent 1478d60 commit 5bf6493
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ describe('determineProjectNamesAndDirectories', () => {
});
});

it('should use provided import path over scoped name when format is "as-provided"', async () => {
const result = await determineProjectNamesAndDirectories(tree, {
name: '@scope/libName',
directory: 'shared',
projectType: 'library',
nameDirectoryFormat: 'as-provided',
importPath: '@custom-scope/lib-name',
});

expect(result).toEqual({
projectName: '@scope/lib-name',
names: {
projectSimpleName: 'lib-name',
projectFileName: 'lib-name',
},
importPath: '@custom-scope/lib-name',
projectDirectory: 'shared',
});
});

it('should return the directory as the project name when directory is not provided and format is "as-provided"', async () => {
updateJson(tree, 'package.json', (json) => {
json.name = 'lib-name';
Expand Down Expand Up @@ -322,6 +342,26 @@ describe('determineProjectNamesAndDirectories', () => {
});
});

it('should use provided import path over scoped name when format is "as-provided"', async () => {
const result = await determineProjectNamesAndDirectories(tree, {
name: '@scope/libName',
directory: 'shared',
projectType: 'library',
nameDirectoryFormat: 'as-provided',
importPath: '@custom-scope/lib-name',
});

expect(result).toEqual({
projectName: '@scope/lib-name',
names: {
projectSimpleName: 'lib-name',
projectFileName: 'lib-name',
},
importPath: '@custom-scope/lib-name',
projectDirectory: 'shared',
});
});

it('should return the directory as the project name when directory is not provided and format is "as-provided"', async () => {
updateJson(tree, 'package.json', (json) => {
json.name = 'lib-name';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function getProjectNameDirectoryFormats(
projectSimpleName: nameWithoutScope,
projectFileName: nameWithoutScope,
},
importPath: asProvidedProjectName,
importPath: options.importPath ?? asProvidedProjectName,
projectDirectory: asProvidedProjectDirectory,
},
},
Expand Down

0 comments on commit 5bf6493

Please sign in to comment.