mirror of
https://github.com/neondatabase/neon.git
synced 2026-08-12 09:19:39 +00:00
Cleanup
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
use std::path::PathBuf;
|
||||
use std::{os::unix::prelude::CommandExt, process::Command};
|
||||
use std::fs::File;
|
||||
|
||||
|
||||
pub trait NeonCommandExtensions: CommandExt {
|
||||
fn capture_to_files(&mut self, path: PathBuf, name: &str) -> &mut Command;
|
||||
}
|
||||
|
||||
impl NeonCommandExtensions for Command {
|
||||
fn capture_to_files(&mut self, path: PathBuf, name: &str) -> &mut Command {
|
||||
let out_file = File::create(path.join(format!("{}.out", name)))
|
||||
.expect("can't make file");
|
||||
let err_file = File::create(path.join(format!("{}.out", name)))
|
||||
.expect("can't make file");
|
||||
|
||||
// TODO touch files?
|
||||
|
||||
self.stdout(out_file).stderr(err_file)
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,9 @@ pub mod nonblock;
|
||||
// Default signal handling
|
||||
pub mod signals;
|
||||
|
||||
// Helpers for running commands
|
||||
pub mod command_extensions;
|
||||
|
||||
/// This is a shortcut to embed git sha into binaries and avoid copying the same build script to all packages
|
||||
///
|
||||
/// we have several cases:
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
use std::{os::unix::prelude::CommandExt, process::Command};
|
||||
|
||||
|
||||
|
||||
/// Command with ability to capture stdout and stderr to files
|
||||
trait CaptureOutputToFile: CommandExt {
|
||||
fn capture_to_file(&mut self) -> &mut Command;
|
||||
}
|
||||
|
||||
impl<C: CommandExt> CaptureOutputToFile
|
||||
Reference in New Issue
Block a user