-
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
57 changed files
with
293 additions
and
198 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
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
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
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
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,59 @@ | ||
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 = if cfg!(test) { | ||
cmd!("env") | ||
} else { | ||
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); | ||
|
||
rtxprint!(out, "{}", cmd.read()?); | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use crate::assert_cli; | ||
use crate::cli::test::grep; | ||
use pretty_assertions::assert_str_eq; | ||
|
||
#[test] | ||
fn test_direnv_exec() { | ||
let stdout = assert_cli!("direnv", "exec"); | ||
assert_str_eq!(grep(stdout, "JDXCODE_TINY="), "JDXCODE_TINY=2.1.0"); | ||
} | ||
} |
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
Oops, something went wrong.