-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
85 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,4 @@ | |
shellcheck 0.9.0 | ||
shfmt 3.6.0 # test comment | ||
#nodejs 18.13.0 | ||
nodejs system | ||
jq latest |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,15 +11,13 @@ assert "rtx local -p" "#python 3.11.1 3.10.9 # foo | |
shellcheck 0.9.0 | ||
shfmt 3.6.0 # test comment | ||
#nodejs 18.13.0 | ||
nodejs system | ||
jq latest | ||
" | ||
|
||
assert "rtx local -p [email protected]" "#python 3.11.1 3.10.9 # foo | ||
shellcheck 0.9.0 | ||
shfmt 3.5.0 # test comment | ||
#nodejs 18.13.0 | ||
nodejs system | ||
jq latest | ||
" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use color_eyre::eyre::Result; | ||
use serde_derive::Deserialize; | ||
|
||
use crate::cli::command::Command; | ||
use crate::cmd; | ||
use crate::config::settings::MissingRuntimeBehavior::{Prompt, Warn}; | ||
use crate::config::Config; | ||
use crate::output::Output; | ||
|
||
/// [internal] This is an internal command that writes an envrc file | ||
/// for direnv to consume. | ||
#[derive(Debug, clap::Args)] | ||
#[clap(verbatim_doc_comment, hide = true)] | ||
pub struct DirenvExec {} | ||
|
||
#[derive(Debug, Default, Deserialize)] | ||
struct DirenvWatches { | ||
#[serde(rename(deserialize = "DIRENV_WATCHES"))] | ||
watches: String, | ||
} | ||
|
||
impl Command for DirenvExec { | ||
fn run(self, mut config: Config, _out: &mut Output) -> Result<()> { | ||
if config.settings.missing_runtime_behavior == Prompt { | ||
config.settings.missing_runtime_behavior = Warn; | ||
} | ||
config.ensure_installed()?; | ||
let mut cmd = cmd!("direnv", "dump"); | ||
|
||
for (k, v) in config.env()? { | ||
cmd = cmd.env(k, v); | ||
} | ||
cmd = cmd.env("PATH", config.path_env()?); | ||
|
||
let json = cmd!("direnv", "watch", "json", ".tool-versions").read()?; | ||
let w: DirenvWatches = serde_json::from_str(&json)?; | ||
cmd = cmd.env("DIRENV_WATCHES", w.watches); | ||
|
||
cmd.run()?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
|
||
use crate::assert_cli; | ||
|
||
use super::*; | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_direnv_exec() { | ||
let Output { .. } = assert_cli!("direnv", "exec"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters