(&self, _config: GlobalConfig)
| 20 | |
| 21 | impl Build { |
| 22 | pub fn run(&self, _config: GlobalConfig) -> CliResult { |
| 23 | let Build { content, output } = self; |
| 24 | let bump = Bump::default(); |
| 25 | let mut str = String::new(); |
| 26 | let start = std::time::Instant::now(); |
| 27 | for (file_name, mut source) in content.sources()? { |
| 28 | let mut source_string = String::new(); |
| 29 | source.read_to_string(&mut source_string)?; |
| 30 | let source_text = source_string.as_str(); |
| 31 | let lexer = Lexer::new(&CssAtomSet::ATOMS, source_text); |
| 32 | let mut parser = Parser::new(&bump, source_text, lexer); |
| 33 | let result = parser.parse_entirely::<StyleSheet>(); |
| 34 | if result.output.is_some() { |
| 35 | let mut stream = CursorCompactWriteSink::new(source_text, &mut str); |
| 36 | result.with_trivia().to_cursors(&mut stream); |
| 37 | } else { |
| 38 | for compact_err in result.errors { |
| 39 | let report = crate::commands::format_diagnostic_error(&compact_err, &source_string, file_name); |
| 40 | println!("{report}"); |
| 41 | } |
| 42 | Err(CliError::ParseFailed)?; |
| 43 | } |
| 44 | } |
| 45 | if let Some(file) = output { |
| 46 | std::fs::write(file, str.as_bytes())?; |
| 47 | } else { |
| 48 | println!("{str}"); |
| 49 | } |
| 50 | eprintln!("Slurped up CSS in {:?}! Neat!", start.elapsed()); |
| 51 | Ok(()) |
| 52 | } |
| 53 | } |
nothing calls this directly
no test coverage detected