Skip to content

Commit

Permalink
fix file path
Browse files Browse the repository at this point in the history
  • Loading branch information
brady.ouren committed Nov 18, 2024
1 parent 6d33c36 commit c5ee481
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
18 changes: 5 additions & 13 deletions components/clarinet-cli/src/frontend/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,8 +1203,11 @@ pub fn main() {

for (file_path, source) in &sources {
let output = formatter.format(source);
println!("output {}", output);
if !cmd.dry_run {
let _ = overwrite_formatted(file_path, output);
} else {
println!("{}", output);
}
}
}
Expand All @@ -1222,13 +1225,10 @@ pub fn main() {
}

fn overwrite_formatted(file_path: &String, output: String) -> io::Result<()> {
// Open the file in write mode, overwriting existing content
let mut file = fs::File::create(file_path)?;

file.write_all(output.as_bytes())?;

// flush the contents to ensure it's written immediately
file.flush()
Ok(())
}

fn get_source_with_path(code_path: Option<String>, file: Option<String>) -> Vec<(String, String)> {
Expand All @@ -1238,7 +1238,7 @@ fn get_source_with_path(code_path: Option<String>, file: Option<String>) -> Vec<

// Collect file paths and load source code
let files: Vec<String> = match file {
Some(file_name) => vec![format!("{}/{}", path, file_name)],
Some(file_name) => vec![format!("{}", file_name)],
None => match fs::read_dir(&path) {
Ok(entries) => entries
.filter_map(Result::ok)
Expand Down Expand Up @@ -1319,14 +1319,6 @@ fn load_manifest_or_warn(path: Option<String>) -> Option<ProjectManifest> {
}
}

fn load_clarity_code(
code_path: &Option<String>,
file: &Option<String>,
dry_run: bool,
) -> (Option<String>) {
Some("".to_string())
}

fn load_deployment_and_artifacts_or_exit(
manifest: &ProjectManifest,
deployment_plan_path: &Option<String>,
Expand Down
4 changes: 1 addition & 3 deletions components/clarinet-format/src/formatter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ impl ClarityFormatter {
ASTRules::Typical,
)
.unwrap();
let output = format_source_exprs(&self.settings, &ast.expressions, "");
println!("output: {}", output);
output
format_source_exprs(&self.settings, &ast.expressions, "")
}
}

Expand Down

0 comments on commit c5ee481

Please sign in to comment.