-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unbundle bash_env.sh as bash-env-json (#33)
The backend Bash script is now shared by nu_plugin_bash_env and bash-env-elvish. It is fetched from the source repo by the Rust build script, so migration should be seamless.
- Loading branch information
1 parent
7a07f34
commit 198554f
Showing
9 changed files
with
208 additions
and
196 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
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use std::{ | ||
env, | ||
path::{Path, PathBuf}, | ||
}; | ||
|
||
const BASH_ENV_JSON_VERSION: &str = "0.6.1"; | ||
|
||
fn fetch_bash_env_json() -> Option<PathBuf> { | ||
let out_dir: PathBuf = env::var("OUT_DIR").unwrap().into(); | ||
let bash_env_json_repo_dir = PathBuf::from("bash-env-json"); | ||
let bash_env_json_repo_path = out_dir.join(bash_env_json_repo_dir.as_path()); | ||
|
||
if Path::exists(&bash_env_json_repo_path) { | ||
Some(bash_env_json_repo_path) | ||
} else { | ||
let bash_env_json_repo_path_str = bash_env_json_repo_path.to_string_lossy(); | ||
let git_args = [ | ||
"clone", | ||
"--filter=blob:none", | ||
"--branch", | ||
BASH_ENV_JSON_VERSION, | ||
"https://github.com/tesujimath/bash-env-json.git", | ||
bash_env_json_repo_path_str.as_ref(), | ||
]; | ||
println!("cargo:warning=git {}", &git_args.join(" ")); | ||
match std::process::Command::new("git").args(git_args).output() { | ||
Ok(output) => { | ||
if output.status.success() { | ||
Some(bash_env_json_repo_path) | ||
} else { | ||
println!( | ||
"cargo:warning=git {:?} failed: {}", | ||
&git_args, output.status | ||
); | ||
|
||
None | ||
} | ||
} | ||
Err(e) => { | ||
println!("cargo:warning=git clone failed: {}", e); | ||
|
||
None | ||
} | ||
} | ||
} | ||
} | ||
|
||
fn main() -> std::io::Result<()> { | ||
if let Some(_bash_env_json_repo_path) = fetch_bash_env_json() { | ||
// TODO what now? | ||
} | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.