feat(migrate): improve multiline string handling

This commit is contained in:
Federico Terzi 2021-05-29 16:28:40 +02:00
parent 21c988c2b4
commit 7d115d588b
3 changed files with 12 additions and 3 deletions

12
Cargo.lock generated
View File

@ -522,7 +522,7 @@ dependencies = [
"test-case", "test-case",
"thiserror", "thiserror",
"walkdir", "walkdir",
"yaml-rust", "yaml-rust 0.4.5 (git+https://github.com/federico-terzi/yaml-rust)",
] ]
[[package]] [[package]]
@ -1412,7 +1412,7 @@ dependencies = [
"dtoa", "dtoa",
"linked-hash-map", "linked-hash-map",
"serde", "serde",
"yaml-rust", "yaml-rust 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -1803,6 +1803,14 @@ dependencies = [
"linked-hash-map", "linked-hash-map",
] ]
[[package]]
name = "yaml-rust"
version = "0.4.5"
source = "git+https://github.com/federico-terzi/yaml-rust#b1a195252fcdabf743f68d03f4d84d151a5a3f62"
dependencies = [
"linked-hash-map",
]
[[package]] [[package]]
name = "zip" name = "zip"
version = "0.5.12" version = "0.5.12"

View File

@ -13,7 +13,7 @@ regex = "1.4.3"
lazy_static = "1.4.0" lazy_static = "1.4.0"
dunce = "1.0.1" dunce = "1.0.1"
walkdir = "2.3.1" walkdir = "2.3.1"
yaml-rust = "0.4.5" yaml-rust = { git = "https://github.com/federico-terzi/yaml-rust" }
path-slash = "0.1.4" path-slash = "0.1.4"
tempdir = "0.3.7" tempdir = "0.3.7"
fs_extra = "1.2.0" fs_extra = "1.2.0"

View File

@ -35,6 +35,7 @@ pub fn render(converted_files: HashMap<String, ConvertedFile>) -> Result<Vec<(St
fn render_file(file: ConvertedFile) -> Result<String> { fn render_file(file: ConvertedFile) -> Result<String> {
let mut dump_str = String::new(); let mut dump_str = String::new();
let mut emitter = YamlEmitter::new(&mut dump_str); let mut emitter = YamlEmitter::new(&mut dump_str);
emitter.multiline_strings(true);
emitter.dump(&Yaml::Hash(file.content))?; emitter.dump(&Yaml::Hash(file.content))?;
let lines: Vec<&str> = dump_str.lines().collect(); let lines: Vec<&str> = dump_str.lines().collect();