MCPcopy Create free account
hub / github.com/cargo-lambda/cargo-lambda / should_ignore_file

Function should_ignore_file

crates/cargo-lambda-new/src/lib.rs:452–498  ·  view source on GitHub ↗
(
    relative: &Path,
    ignore_files: &[PathBuf],
    template_config: &TemplateConfig,
    variables: &Object,
)

Source from the content-addressed store, hash-verified

450}
451
452fn should_ignore_file(
453 relative: &Path,
454 ignore_files: &[PathBuf],
455 template_config: &TemplateConfig,
456 variables: &Object,
457) -> bool {
458 if ignore_files.contains(&relative.to_path_buf()) {
459 return true;
460 }
461
462 let Some(unix_path) = convert_to_unix_path(relative) else {
463 return false;
464 };
465
466 if ignore_files.contains(&PathBuf::from(&unix_path)) {
467 return true;
468 }
469
470 let condition = template_config
471 .ignore_conditional_files
472 .get(&unix_path)
473 .or_else(|| {
474 relative
475 .to_str()
476 .and_then(|s| template_config.ignore_conditional_files.get(s))
477 });
478
479 if let Some(condition) = condition {
480 let Some(variable) = variables.get::<str>(&condition.var) else {
481 return false;
482 };
483
484 if let Some(condition_value) = &condition.r#match
485 && condition_value.to_value() == *variable
486 {
487 return true;
488 }
489
490 if let Some(condition_value) = &condition.not_match
491 && condition_value.to_value() != *variable
492 {
493 return true;
494 }
495 }
496
497 false
498}
499
500fn render_path_with_variables(path: &Path, parser: &Parser, variables: &Object) -> Option<PathBuf> {
501 let re = regex::Regex::new(r"\{\{[^/]*\}\}").ok()?;

Callers 1

create_projectFunction · 0.85

Calls 3

getMethod · 0.80
to_valueMethod · 0.80
convert_to_unix_pathFunction · 0.70

Tested by

no test coverage detected