Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

## main

- [ADD] `serve` コマンドで初回ビルドおよび再ビルド時に処理時間を表示
- [FIX] `serve` コマンドで `ls` 実行時にビルドが誤って走る問題を修正
- `notify-debouncer-mini` から `notify-debouncer-full` に移行し、`EventKind::Access` を除外するようにした
- [#46](https://github.com/veltiosoft/vss/pull/46)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 18 additions & 6 deletions src/subcommand_serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ use std::{
net::SocketAddr,
path::{Path, PathBuf},
sync::{Arc, Mutex},
time::Duration,
time::{Duration, Instant},
};
use tower_http::services::ServeDir;

use crate::subcommand_build;

/// ビルドを実行し、処理時間を返す
fn run_build_with_timing(config_path: &Path) -> Result<Duration> {
let start = Instant::now();
subcommand_build::run_build(config_path)?;
Ok(start.elapsed())
}

/// serve コマンドのエントリポイント
pub fn run(mut args: noargs::RawArgs) -> noargs::Result<()> {
let config: Option<PathBuf> = noargs::opt("config")
Expand Down Expand Up @@ -62,8 +69,9 @@ pub fn run(mut args: noargs::RawArgs) -> noargs::Result<()> {
async fn run_serve(config_path: &Path, port: u16) -> Result<()> {
// 初回ビルド
println!("[INFO] Running initial build...");
subcommand_build::run_build(config_path)?;
let duration = run_build_with_timing(config_path)?;
println!("[INFO] Initial build completed");
println!("build finished in {} ms", duration.as_millis());

// 設定を読み込んで dist ディレクトリを取得
let dist_dir = get_dist_dir(config_path)?;
Expand Down Expand Up @@ -145,10 +153,14 @@ fn watch_files(config_path: &Path, _rebuild_flag: Arc<Mutex<bool>>) -> Result<()

if should_rebuild {
println!("[INFO] File changed, rebuilding...");
if let Err(e) = subcommand_build::run_build(&config_path_clone) {
eprintln!("[ERROR] Rebuild failed: {:#}", e);
} else {
println!("[INFO] Rebuild completed");
match run_build_with_timing(&config_path_clone) {
Ok(duration) => {
println!("[INFO] Rebuild completed");
println!("build finished in {} ms", duration.as_millis());
}
Err(e) => {
eprintln!("[ERROR] Rebuild failed: {:#}", e);
}
}
}
}
Expand Down