Skip to content

Commit

Permalink
fix: add condition to preserve project-name with gradle monitor (#4906)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroymoore committed Oct 30, 2023
1 parent 068b111 commit 351c7bd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/monitor/utils.ts
Expand Up @@ -43,7 +43,7 @@ export function getProjectName(
return scannedProject.meta.projectName;
}

if (scannedProject.meta?.gradleProjectName) {
if (scannedProject.meta?.gradleProjectName && !meta['project-name']) {
return scannedProject.meta.gradleProjectName;
}

Expand Down
18 changes: 18 additions & 0 deletions test/jest/unit/cli-monitor-utils.spec.ts
Expand Up @@ -155,6 +155,24 @@ describe('cli-monitor-utils test', () => {
expect(res).toEqual('meta-gradle-project');
});

it('getProjectName returns project name when project-name is provided via option', () => {
const scannedProject: ScannedProject = {
depGraph: {} as any,
meta: { gradleProjectName: 'my-gradle-project' },
targetFile: '/tmp/build.gradle',
};

const res = utils.getProjectName(scannedProject, {
method: 'cli',
packageManager: 'gradle',
'policy-path': '',
'project-name': 'project-name-from-option',
isDocker: false,
prune: false,
});
expect(res).toEqual('project-name-from-option');
});

it('getTargetFile returns name from scanned project if container', () => {
const scannedProject: ScannedProject = stubScannedProjectContainer();
const res = utils.getTargetFile(scannedProject, getStubPluginMeta());
Expand Down

0 comments on commit 351c7bd

Please sign in to comment.