diff --git a/packages/shorebird_cli/lib/src/executables/powershell.dart b/packages/shorebird_cli/lib/src/executables/powershell.dart index 76d5e54f4..fc03e97ae 100644 --- a/packages/shorebird_cli/lib/src/executables/powershell.dart +++ b/packages/shorebird_cli/lib/src/executables/powershell.dart @@ -47,6 +47,10 @@ class Powershell { runInShell: true, ); - return (result.stdout as String).trim(); + var versionString = (result.stdout as String).trim(); + if (!versionString.contains('+')) { + versionString += '+0'; + } + return versionString; } } diff --git a/packages/shorebird_cli/test/src/executables/powershell_test.dart b/packages/shorebird_cli/test/src/executables/powershell_test.dart index 8f339a171..bb3bad2dd 100644 --- a/packages/shorebird_cli/test/src/executables/powershell_test.dart +++ b/packages/shorebird_cli/test/src/executables/powershell_test.dart @@ -56,16 +56,33 @@ void main() { }); group('when exit code is success', () { - setUp(() { - when(() => processResult.exitCode).thenReturn(0); - when(() => processResult.stdout).thenReturn('1.0.0'); + group('when version code includes a build number', () { + setUp(() { + when(() => processResult.exitCode).thenReturn(0); + when(() => processResult.stdout).thenReturn('1.0.0+1'); + }); + + test('returns unaltered version string', () async { + final version = await runWithOverrides( + () => powershell.getExeVersionString(File('')), + ); + expect(version, '1.0.0+1'); + }); }); - test('returns the version string', () async { - final version = await runWithOverrides( - () => powershell.getExeVersionString(File('')), - ); - expect(version, '1.0.0'); + group('when version code does not include a build number', () { + setUp(() { + when(() => processResult.exitCode).thenReturn(0); + when(() => processResult.stdout).thenReturn('1.0.0'); + }); + + test('returns the version string with build number 0 added', + () async { + final version = await runWithOverrides( + () => powershell.getExeVersionString(File('')), + ); + expect(version, '1.0.0+0'); + }); }); }); });