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",
"thiserror",
"walkdir",
"yaml-rust",
"yaml-rust 0.4.5 (git+https://github.com/federico-terzi/yaml-rust)",
]
[[package]]
@ -1412,7 +1412,7 @@ dependencies = [
"dtoa",
"linked-hash-map",
"serde",
"yaml-rust",
"yaml-rust 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1803,6 +1803,14 @@ dependencies = [
"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]]
name = "zip"
version = "0.5.12"

View File

@ -13,7 +13,7 @@ regex = "1.4.3"
lazy_static = "1.4.0"
dunce = "1.0.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"
tempdir = "0.3.7"
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> {
let mut dump_str = String::new();
let mut emitter = YamlEmitter::new(&mut dump_str);
emitter.multiline_strings(true);
emitter.dump(&Yaml::Hash(file.content))?;
let lines: Vec<&str> = dump_str.lines().collect();