Skip to content

Commit

Permalink
env-man
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 26, 2024
1 parent 91b9fc1 commit afd0c64
Show file tree
Hide file tree
Showing 24 changed files with 689 additions and 399 deletions.
15 changes: 7 additions & 8 deletions src/cli/hook_env.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::env::{join_paths, split_paths};
use std::ops::Deref;
use std::path::PathBuf;
use std::path::{Path, PathBuf};

use console::truncate_str;
use eyre::Result;
Expand Down Expand Up @@ -35,11 +35,7 @@ pub struct HookEnv {
impl HookEnv {
pub fn run(self) -> Result<()> {
let config = Config::try_get()?;
let watch_files: Vec<_> = config
.config_files
.values()
.flat_map(|p| p.watch_files())
.collect();
let watch_files = config.watch_files()?;
if hook_env::should_exit_early(&watch_files) {
return Ok(());
}
Expand All @@ -51,7 +47,7 @@ impl HookEnv {
let mut diff = EnvDiff::new(&env::PRISTINE_ENV, env);
let mut patches = diff.to_patches();

let mut paths = config.path_dirs.clone();
let mut paths = config.path_dirs()?.clone();
if let Some(p) = env_path {
paths.extend(split_paths(&p).collect_vec());
}
Expand Down Expand Up @@ -165,7 +161,10 @@ impl HookEnv {
))
}

fn build_watch_operation(&self, watch_files: &[PathBuf]) -> Result<EnvDiffOperation> {
fn build_watch_operation(
&self,
watch_files: impl IntoIterator<Item = impl AsRef<Path>>,
) -> Result<EnvDiffOperation> {
let watches = hook_env::build_watches(watch_files)?;
Ok(EnvDiffOperation::Add(
"__MISE_WATCH".into(),
Expand Down
2 changes: 1 addition & 1 deletion src/cli/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl Set {
.map(|(key, (value, source))| Row {
key: key.clone(),
value: value.clone(),
source: display_path(source),
source: display_path(&source),
})
.collect::<Vec<_>>();
let mut table = tabled::Table::new(rows);
Expand Down
Loading

0 comments on commit afd0c64

Please sign in to comment.