Skip to content

Commit

Permalink
refactor(actions): remove artificial delay when performing replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
norskeld committed Mar 10, 2024
1 parent 51ff257 commit 8b3425d
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions src/actions/actions.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::path::{Path, PathBuf};
use std::process;
use std::thread;
use std::time::{Duration, Instant};

use crossterm::style::Stylize;
use miette::Diagnostic;
Expand Down Expand Up @@ -289,7 +287,6 @@ impl Replace {
P: AsRef<Path>,
{
let spinner = Spinner::new();
let start = Instant::now();

// If no glob pattern specified, traverse all files.
let pattern = self.glob.clone().unwrap_or("**/*".to_string());
Expand Down Expand Up @@ -351,14 +348,6 @@ impl Replace {
})?;
}

// Add artificial delay if replacements were performed too fast.
let elapsed = start.elapsed();

// This way we spent at least 1 second before stopping the spinner.
if elapsed < Duration::from_millis(750) {
thread::sleep(Duration::from_millis(1_000) - elapsed);
}

spinner.stop_with_message("Successfully performed replacements\n");
}

Expand Down

0 comments on commit 8b3425d

Please sign in to comment.