From a652e3e43a794cf45a73fc91c8bddd71855a1dec Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Thu, 18 May 2023 15:25:23 -0500 Subject: [PATCH] gen --- .gitignore | 1 + src/html.rs | 1 + src/index.rs | 1 + src/main.rs | 22 +++++++++++++++------- 4 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 src/html.rs create mode 100644 src/index.rs diff --git a/.gitignore b/.gitignore index 2d5df85..e42d97c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target .direnv +node_modules \ No newline at end of file diff --git a/src/html.rs b/src/html.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/html.rs @@ -0,0 +1 @@ + diff --git a/src/index.rs b/src/index.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/index.rs @@ -0,0 +1 @@ + diff --git a/src/main.rs b/src/main.rs index 8dfffb0..89f227f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +pub mod html; +pub mod index; pub mod progress_bar; pub mod walkdir; @@ -14,7 +16,7 @@ use indicatif::{ProgressBar, ProgressStyle}; use swc_common::errors::ColorConfig; use swc_common::{errors::Handler, sync::Lrc}; use swc_common::{FileName, SourceMap}; -use swc_ecma_ast::ModuleDecl; +use swc_ecma_ast::{Decl, FnDecl, ModuleDecl}; use swc_ecma_parser::TsConfig; use swc_ecma_parser::{ lexer::Lexer as EcmaLexer, Parser as EcmaParser, StringInput, Syntax, @@ -168,22 +170,28 @@ async fn handle_data( }) .expect("failed to parser module"); - tx.send(BarAction::Print(format!("Parsed module. {}", path_display)))?; - for item in module.body.iter() { - tx.send(BarAction::Print(format!("SHIET {item:?}")))?; let decl = match item.as_module_decl() { Some(v) => v, None => continue, }; match decl { - ModuleDecl::ExportDecl(decl) => { - tx.send(BarAction::Print(format!("SHIET {decl:?}")))?; - } + ModuleDecl::ExportDecl(decl) => match &decl.decl { + Decl::Fn(fn_decl) => { + let name = fn_decl.ident.to_string(); + tx.send(BarAction::Print(format!("SHIET {name}")))?; + } + _ => {} + }, _ => {} } } + tx.send(BarAction::Print(format!( + "Processed module {}.", + path_display + )))?; + Ok(()) }