fmt
This commit is contained in:
parent
f800d63e02
commit
91711c9e07
37
.pre-commit-config.yaml
Normal file
37
.pre-commit-config.yaml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v5.0.0
|
||||||
|
hooks:
|
||||||
|
# - id: no-commit-to-branch
|
||||||
|
# args: [--branch, master, --branch, main, --pattern, release/.*]
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: check-yaml
|
||||||
|
- id: check-added-large-files
|
||||||
|
- id: mixed-line-ending
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- id: check-shebang-scripts-are-executable
|
||||||
|
- id: check-executables-have-shebangs
|
||||||
|
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: clippy
|
||||||
|
name: clippy
|
||||||
|
language: system
|
||||||
|
entry: cargo clippy
|
||||||
|
pass_filenames: false
|
||||||
|
always_run: true
|
||||||
|
|
||||||
|
- id: cargo-fmt
|
||||||
|
name: cargo fmt
|
||||||
|
language: system
|
||||||
|
entry: cargo fmt
|
||||||
|
pass_filenames: false
|
||||||
|
always_run: true
|
||||||
|
|
||||||
|
- id: check-todos # [NOGREP]
|
||||||
|
name: check-todos # [NOGREP]
|
||||||
|
language: system
|
||||||
|
entry: sh -c "! grep --color=always --binary-files=without-match --dereference-recursive --exclude-dir='notes' --exclude-dir='node_modules' --exclude-dir='.git' --exclude='.pre-commit-config.yaml' --exclude-dir='venv' 'TODO'" # [NOGREP]
|
||||||
|
pass_filenames: false
|
||||||
|
always_run: true
|
||||||
13
src/main.rs
13
src/main.rs
@ -7,7 +7,6 @@ use axum::{
|
|||||||
};
|
};
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use notify::{Config, EventKind, RecommendedWatcher, RecursiveMode, Watcher};
|
use notify::{Config, EventKind, RecommendedWatcher, RecursiveMode, Watcher};
|
||||||
use pulldown_cmark;
|
|
||||||
use pulldown_cmark::{CodeBlockKind, Event, Options, Tag, html};
|
use pulldown_cmark::{CodeBlockKind, Event, Options, Tag, html};
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
use std::net::{SocketAddr, ToSocketAddrs};
|
use std::net::{SocketAddr, ToSocketAddrs};
|
||||||
@ -114,7 +113,7 @@ fn resolve_addr(host: &str, port: u16) -> io::Result<SocketAddr> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn root(State(state): State<AppState>) -> Result<Html<String>, StatusCode> {
|
async fn root(State(state): State<AppState>) -> Result<Html<String>, StatusCode> {
|
||||||
render_directory_index(&PathBuf::from(state.root), "").await
|
render_directory_index(&state.root, "").await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn sse_handler(
|
async fn sse_handler(
|
||||||
@ -342,11 +341,11 @@ async fn run_file_watcher(state: AppState) {
|
|||||||
let tx_fs_clone = tx_fs.clone();
|
let tx_fs_clone = tx_fs.clone();
|
||||||
let mut watcher = RecommendedWatcher::new(
|
let mut watcher = RecommendedWatcher::new(
|
||||||
move |res: Result<notify::Event, notify::Error>| {
|
move |res: Result<notify::Event, notify::Error>| {
|
||||||
if let Ok(event) = res {
|
if let Ok(event) = res
|
||||||
if matches!(event.kind, EventKind::Modify(_)) {
|
&& matches!(event.kind, EventKind::Modify(_))
|
||||||
for path in event.paths {
|
{
|
||||||
let _ = tx_fs_clone.blocking_send(path);
|
for path in event.paths {
|
||||||
}
|
let _ = tx_fs_clone.blocking_send(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user