website/scripts: Add docsmg migration tool (#10658)
* add docsmg tool * moved to the correct scripts directory * removed test files
This commit is contained in:
21
website/scripts/docsmg/src/migratefile.rs
Normal file
21
website/scripts/docsmg/src/migratefile.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use std::{fs::read_to_string, path::PathBuf};
|
||||
|
||||
pub fn read_migrate_file(file: PathBuf) -> anyhow::Result<Vec<(PathBuf, PathBuf)>> {
|
||||
let contents = read_to_string(file)?;
|
||||
let lines: Vec<String> = contents
|
||||
.split('\n')
|
||||
.map(|x| x.to_owned())
|
||||
.filter(|x| x != "")
|
||||
.collect();
|
||||
let migrations = lines
|
||||
.iter()
|
||||
.filter_map(|x| x.split_once(" -> "))
|
||||
.map(|x| {
|
||||
(
|
||||
x.0.parse().expect("a valid path"),
|
||||
x.1.parse().expect("a valid path"),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
Ok(migrations)
|
||||
}
|
||||
Reference in New Issue
Block a user