-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retain comments and linebreaks when writting new yaml #19
Conversation
OK, so I discussed this with a friend. Yaml seems to be trickier than I thought. For instance, what if the version: 0.2.3 # lol parse me Or what if there is a multiline string? version: 0.2.3 # i am the version line
description: 'and I am a line with a
version: 3.2.1
in it' I don't see an easy way to avoid using a real yaml parser. |
Yes good thought, you are right about that. But nothing a little regex can't fix. We just use a positive lookahead and match the version which is not contained in Can you think of any other tests or problems? |
@@ -1,6 +1,10 @@ | |||
description: "A CLI tool to set/bump the `version` key in pubspec.yaml." | |||
description: "A CLI tool to set/bump the `version` key in pubspec.yaml. | |||
version: 1.2.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a test checking this line is not getting changed?
Future _writeNewPubSpec( | ||
File pubSpec, Version oldVersion, Version newVersion) async { | ||
String newPubSpec = pubSpec.readAsStringSync().replaceFirst( | ||
'version: "${oldVersion}"', "version: " + '"${newVersion.toString()}"'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how different quotation is processed. This line seems to only deal with double quotes. Is there a test for double/single/no quotes?
|
||
import 'package:pub_semver/pub_semver.dart'; | ||
|
||
abstract class VersionExtractor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it a class and why is the class abstract? A simple function would be enough.
Resolves #17 by parsing and updating version in place.