Skip to content

Commit 50fdadc

Browse files
committed
fix framework detection
1 parent dfca9fc commit 50fdadc

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

crates/smbcloud-model/src/runner.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
use {
22
crate::error_codes::{ErrorCode::UnsupportedRunner, ErrorResponse},
33
serde::{Deserialize, Serialize},
4-
std::{fs, path::PathBuf},
4+
std::{
5+
fmt::{self, Display, Formatter},
6+
fs,
7+
path::PathBuf,
8+
},
59
};
610

711
#[derive(Debug, Serialize, Deserialize)]
@@ -12,6 +16,12 @@ pub enum Runner {
1216
Swift,
1317
}
1418

19+
impl Display for Runner {
20+
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
21+
write!(f, "{:?}", self)
22+
}
23+
}
24+
1525
#[derive(Debug, Serialize, Deserialize)]
1626
#[tsync::tsync]
1727
pub enum NodeJsFramework {
@@ -34,11 +44,11 @@ pub enum SwiftFramework {
3444
impl Runner {
3545
pub fn from(repo_path: &PathBuf) -> Result<Runner, ErrorResponse> {
3646
if repo_path.join("package.json").exists()
37-
&& (next_config_exists() || astro_config_exists())
47+
&& (next_config_exists(repo_path) || astro_config_exists(repo_path))
3848
{
39-
if next_config_exists() {
49+
if next_config_exists(repo_path) {
4050
return Ok(Runner::NodeJs);
41-
} else if astro_config_exists() {
51+
} else if astro_config_exists(repo_path) {
4252
return Ok(Runner::NodeJs);
4353
} else {
4454
return Err(ErrorResponse::Error {
@@ -62,8 +72,8 @@ impl Runner {
6272
}
6373

6474
// Helper function to detect any next.config.* file
65-
fn next_config_exists() -> bool {
66-
if let Ok(entries) = fs::read_dir(".") {
75+
fn next_config_exists(repo_path: &PathBuf) -> bool {
76+
if let Ok(entries) = fs::read_dir(repo_path) {
6777
for entry in entries.flatten() {
6878
let filename = entry.file_name();
6979
let filename_str = filename.to_string_lossy();
@@ -76,8 +86,8 @@ fn next_config_exists() -> bool {
7686
}
7787

7888
// Helper function to detect any astro.config.* file
79-
fn astro_config_exists() -> bool {
80-
if let Ok(entries) = fs::read_dir(".") {
89+
fn astro_config_exists(repo_path: &PathBuf) -> bool {
90+
if let Ok(entries) = fs::read_dir(repo_path) {
8191
for entry in entries.flatten() {
8292
let filename = entry.file_name();
8393
let filename_str = filename.to_string_lossy();

0 commit comments

Comments
 (0)