MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / find_module_path

Function find_module_path

crates/cli/src/util.rs:239–248  ·  view source on GitHub ↗

Try to find a SpacetimeDB module directory, checking in order: 1. `{project_dir}/spacetimedb/` subdirectory 2. `{project_dir}` itself Returns the first path that contains a recognizable SpacetimeDB module, or `None`.

(project_dir: &Path)

Source from the content-addressed store, hash-verified

237///
238/// Returns the first path that contains a recognizable SpacetimeDB module, or `None`.
239pub fn find_module_path(project_dir: &Path) -> Option<PathBuf> {
240 let spacetimedb_subdir = project_dir.join("spacetimedb");
241 if spacetimedb_subdir.is_dir() && detect_module_language(&spacetimedb_subdir).is_ok() {
242 return Some(spacetimedb_subdir);
243 }
244 if project_dir.is_dir() && detect_module_language(project_dir).is_ok() {
245 return Some(project_dir.to_path_buf());
246 }
247 None
248}
249
250pub fn detect_module_language(path_to_module: &Path) -> anyhow::Result<ModuleLanguage> {
251 // TODO: Possible add a config file durlng spacetime init with the language

Callers 2

execFunction · 0.85
execFunction · 0.85

Calls 3

detect_module_languageFunction · 0.85
joinMethod · 0.80
is_okMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…