Advertisement
Guest User

Untitled

a guest
Apr 20th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 1.34 KB | None | 0 0
  1. fn getStr() -> String {
  2.     fs::copy("../client/src/elm/Main.elm",
  3.              "../client/src/elm/Main.elm.bak")
  4.             .expect("file not copied");
  5.     let stdout: Vec<u8>;
  6.     {
  7.         let mut main_file = OpenOptions::new()
  8.             .append(true)
  9.             .open("../client/src/elm/Main.elm")
  10.             .expect("file not opened");
  11.  
  12.         let str1 = format!(r#"
  13. view : Html Msg
  14. view =
  15.    viewWithModel <|
  16.        Model [] HomeRoute <|
  17.            Flags "" {time} ""
  18. "#,
  19.                            time = time::get_time().sec);
  20.  
  21.         main_file
  22.             .write(str1.as_bytes())
  23.             .expect("file content not saved");
  24.  
  25.         stdout = Command::new("node")
  26.             .current_dir(&Path::new("../client"))
  27.             .arg("./node_modules/elm-static-html/index.js")
  28.             .arg("-f")
  29.             .arg("src/elm/Main.elm")
  30.             .output()
  31.             .expect("elm-static-html command failed to start")
  32.             .stdout;
  33.  
  34.  
  35.     }
  36.     fs::rename("../client/src/elm/Main.elm.bak",
  37.                "../client/src/elm/Main.elm")
  38.             .expect("file not renamed");
  39.  
  40.     String::from_utf8_lossy(&*stdout)
  41.         .lines()
  42.         .skip_while(|x| {
  43.                         // x.d;
  44.                         x.find("class \"content\"").is_none()
  45.                     })
  46.         .collect()
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement