Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/updaters/dart/pubspec-yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class PubspecYaml extends DefaultUpdater {
*/

updateContent(content: string, logger: Logger = defaultLogger): string {
const oldVersion = content.match(/^version: ([0-9.]+)\+?(.*$)/m);
const oldVersion = content.match(/^version: ([0-9]+\.[0-9]+\.[0-9]+(?:-[^\s+]+)?)\+?(.*$)/m);
let buildNumber = '';

if (oldVersion) {
Expand Down
8 changes: 8 additions & 0 deletions test/updaters/fixtures/pubspec_prerelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: hello_world
description: Hello World
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 0.5.0-beta.1

environment:
sdk: '>=2.12.0 <3.0.0'
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: hello_world
description: Hello World
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 0.5.0-beta.1+5

environment:
sdk: '>=2.12.0 <3.0.0'
23 changes: 23 additions & 0 deletions test/updaters/pubspec-yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,28 @@ describe('PubspecYaml', () => {
const newContent = version.updateContent(oldContent);
snapshot(newContent);
});
it('updates prerelease version in pubspec.yaml file', async () => {
const oldContent = readFileSync(
resolve(fixturesPath, './pubspec_prerelease.yaml'),
'utf8'
).replace(/\r\n/g, '\n'); // required for windows
const version = new PubspecYaml({
version: Version.parse('0.6.0'),
});
const newContent = version.updateContent(oldContent);
snapshot(newContent);
});

it('updates prerelease version with build number in pubspec.yaml file', async () => {
const oldContent = readFileSync(
resolve(fixturesPath, './pubspec_prerelease_with_build_no.yaml'),
'utf8'
).replace(/\r\n/g, '\n'); // required for windows
const version = new PubspecYaml({
version: Version.parse('0.6.0'),
});
const newContent = version.updateContent(oldContent);
snapshot(newContent);
});
});
});
Loading