mirror of
https://github.com/chmln/sd
synced 2024-11-22 11:13:04 +00:00
commit
9ab3372026
2 changed files with 8 additions and 6 deletions
|
@ -78,7 +78,6 @@ impl App {
|
||||||
let file =
|
let file =
|
||||||
unsafe { memmap::Mmap::map(&File::open(path)?)? };
|
unsafe { memmap::Mmap::map(&File::open(path)?)? };
|
||||||
if self.replacer.has_matches(&file) {
|
if self.replacer.has_matches(&file) {
|
||||||
println!("{}", path.display());
|
|
||||||
handle
|
handle
|
||||||
.write_all(&self.replacer.replace_preview(&file))?;
|
.write_all(&self.replacer.replace_preview(&file))?;
|
||||||
}
|
}
|
||||||
|
|
13
tests/cli.rs
13
tests/cli.rs
|
@ -46,11 +46,14 @@ mod cli {
|
||||||
let mut file = tempfile::NamedTempFile::new()?;
|
let mut file = tempfile::NamedTempFile::new()?;
|
||||||
file.write(b"abc123def")?;
|
file.write(b"abc123def")?;
|
||||||
|
|
||||||
#[rustfmt::skip]
|
sd().args(&["-p", "abc\\d+", "", file.path().to_str().unwrap()])
|
||||||
sd().args(&["-p", "abc\\d+", "", file.path().to_str().unwrap()])
|
.assert()
|
||||||
.assert()
|
.success()
|
||||||
.success()
|
.stdout(format!(
|
||||||
.stdout("def");
|
"{}{}def",
|
||||||
|
ansi_term::Color::Green.prefix().to_string(),
|
||||||
|
ansi_term::Color::Green.suffix().to_string()
|
||||||
|
));
|
||||||
|
|
||||||
assert_file(file.path(), "abc123def");
|
assert_file(file.path(), "abc123def");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue