Skip to content

Commit

Permalink
Limit krpc_build definition listing to *.json
Browse files Browse the repository at this point in the history
  • Loading branch information
kladd committed Nov 9, 2024
1 parent be98793 commit 1e9cccb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions krpc_build/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{env, fs, io, path::Path};
use std::{env, ffi::OsStr, fs, io, path::Path};

use convert_case::{Case, Casing};
use proc_macro2::TokenStream;
Expand Down Expand Up @@ -53,8 +53,11 @@ pub fn build<O: io::Write>(
out: &mut O,
) -> Result<(), io::Error> {
for service_definition_path in fs::read_dir(service_definitions)? {
let service_definition_file =
fs::File::open(service_definition_path.unwrap().path())?;
let path = service_definition_path.unwrap().path();
if !matches!(path.extension().and_then(OsStr::to_str), Some("json")) {
continue;
}
let service_definition_file = fs::File::open(path)?;
let service_definition_json: Value =
serde_json::from_reader(service_definition_file)?;

Expand Down

0 comments on commit 1e9cccb

Please sign in to comment.