Skip to content

Commit 3930dad

Browse files
authored
updates for the next version of package:yaml (dart-archive/yaml_edit#45)
1 parent 6d3e93f commit 3930dad

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

pkgs/yaml_edit/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.1.1
2+
3+
- Update to work with an unreleased version of `package:yaml`.
4+
15
## 2.1.0
26
- **Breaking** `wrapAsYamlNode(value, collectionStyle, scalarStyle)` will apply
37
`collectionStyle` and `scalarStyle` recursively when wrapping a children of

pkgs/yaml_edit/lib/src/strings.dart

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,14 @@ String _yamlEncodeFlowScalar(YamlNode value) {
139139
assertValidScalar(value.value);
140140

141141
if (value.value is String) {
142-
if (_hasUnprintableCharacters(value.value) ||
142+
final val = value.value as String;
143+
if (_hasUnprintableCharacters(val) ||
143144
value.style == ScalarStyle.DOUBLE_QUOTED) {
144-
return _yamlEncodeDoubleQuoted(value.value);
145+
return _yamlEncodeDoubleQuoted(val);
145146
}
146147

147148
if (value.style == ScalarStyle.SINGLE_QUOTED) {
148-
return _tryYamlEncodeSingleQuoted(value.value);
149+
return _tryYamlEncodeSingleQuoted(val);
149150
}
150151
}
151152

@@ -172,23 +173,23 @@ String yamlEncodeBlockScalar(
172173
assertValidScalar(value.value);
173174

174175
if (value.value is String) {
175-
if (_hasUnprintableCharacters(value.value)) {
176-
return _yamlEncodeDoubleQuoted(value.value);
176+
final val = value.value as String;
177+
if (_hasUnprintableCharacters(val)) {
178+
return _yamlEncodeDoubleQuoted(val);
177179
}
178180

179181
if (value.style == ScalarStyle.SINGLE_QUOTED) {
180-
return _tryYamlEncodeSingleQuoted(value.value);
182+
return _tryYamlEncodeSingleQuoted(val);
181183
}
182184

183185
// Strings with only white spaces will cause a misparsing
184-
if (value.value.trim().length == value.value.length &&
185-
value.value.length != 0) {
186+
if (val.trim().length == val.length && val.isNotEmpty) {
186187
if (value.style == ScalarStyle.FOLDED) {
187-
return _tryYamlEncodeFolded(value.value, indentation, lineEnding);
188+
return _tryYamlEncodeFolded(val, indentation, lineEnding);
188189
}
189190

190191
if (value.style == ScalarStyle.LITERAL) {
191-
return _tryYamlEncodeLiteral(value.value, indentation, lineEnding);
192+
return _tryYamlEncodeLiteral(val, indentation, lineEnding);
192193
}
193194
}
194195
}

pkgs/yaml_edit/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: yaml_edit
2-
version: 2.1.0
2+
version: 2.1.1
33
description: A library for YAML manipulation with comment and whitespace preservation.
44
repository: https://github.com/dart-lang/yaml_edit
55
issue_tracker: https://github.com/dart-lang/yaml_edit/issues

0 commit comments

Comments
 (0)