Skip to content

Commit

Permalink
feat: add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed May 25, 2022
1 parent b36d1e6 commit 4be6387
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/bumper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const {
getNewProjectContentCsproj,
getCurrentVersionAssembly,
getCommitMessages,
getRelevantCommitMessages
getRelevantCommitMessages,
logError
} = require('./utils');

module.exports = async (
Expand Down Expand Up @@ -48,7 +49,11 @@ module.exports = async (
} else if (type === 'assembly') {
currentVersion = getCurrentVersionAssembly(projectFile);
} else {
logInfo(`Type not recognized: ${type}`);
logError(`Type not recognized: ${type}`);
return false;
}
if (currentVersion === undefined) {
logError(`Could not find the current version as it was undefined: ${currentVersion}`);
return false;
}
core.setOutput('oldVersion', currentVersion);
Expand Down
30 changes: 30 additions & 0 deletions test/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,36 @@ describe('Utils', () => {
const version = getCurrentVersionCsproj(csproj);
expect(version).toEqual('1.0.0');
});

test('should return version 2', () => {
const csproj = `
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net461</TargetFrameworks>
<RootNamespace>Asyncapi.Nats.Client</RootNamespace>
<Version>0.1.0</Version>
<PackageVersion>0.1.0</PackageVersion>
<AssemblyVersion>0.1.0.0</AssemblyVersion>
<FileVersion>0.1.0.0</FileVersion>
<RepositoryUrl>https://github.com/GamingAPI/rust-csharp-game-api.git</RepositoryUrl>
</PropertyGroup>
<ItemGroup>
<None Remove="NATS.Client" />
<None Remove="System.Text.Json" />
<None Remove="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NATS.Client" Version="0.12.0" />
<PackageReference Include="System.Text.Json" Version="5.0.2" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>
</Project>
`;
const version = getCurrentVersionCsproj(csproj);
expect(version).toEqual('0.1.0');
});
test('should return undefined when no version present', () => {
const csproj = `<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
Expand Down

0 comments on commit 4be6387

Please sign in to comment.