mirror of
https://github.com/casey/just.git
synced 2024-11-23 02:44:56 +03:00
Allow unstable features to be enabled with environment variable (#1588)
This commit is contained in:
parent
d17401e4b1
commit
992c6943da
@ -325,7 +325,8 @@ This does not, however, preclude fixing outright bugs, even if doing so might br
|
||||
|
||||
There will never be a `just` 2.0. Any desirable backwards-incompatible changes will be opt-in on a per-`justfile` basis, so users may migrate at their leisure.
|
||||
|
||||
Features that aren't yet ready for stabilization are gated behind the `--unstable` flag. Features enabled by `--unstable` may change in backwards incompatible ways at any time.
|
||||
Features that aren't yet ready for stabilization are gated behind the `--unstable` flag. Features enabled by `--unstable` may change in backwards incompatible ways at any time. Unstable features can also be enabled by setting the environment variable `JUST_UNSTABLE` to any value other than `false`, `0`, or the empty string.
|
||||
|
||||
|
||||
Editor Support
|
||||
--------------
|
||||
|
@ -569,6 +569,11 @@ impl Config {
|
||||
None
|
||||
};
|
||||
|
||||
let unstable = matches.is_present(arg::UNSTABLE)
|
||||
|| std::env::var_os("JUST_UNSTABLE")
|
||||
.map(|val| !(val == "false" || val == "0" || val.is_empty()))
|
||||
.unwrap_or_default();
|
||||
|
||||
Ok(Self {
|
||||
check: matches.is_present(arg::CHECK),
|
||||
dry_run: matches.is_present(arg::DRY_RUN),
|
||||
@ -578,7 +583,7 @@ impl Config {
|
||||
load_dotenv: !matches.is_present(arg::NO_DOTENV),
|
||||
shell_command: matches.is_present(arg::SHELL_COMMAND),
|
||||
unsorted: matches.is_present(arg::UNSORTED),
|
||||
unstable: matches.is_present(arg::UNSTABLE),
|
||||
unstable,
|
||||
list_heading: matches
|
||||
.value_of(arg::LIST_HEADING)
|
||||
.unwrap_or("Available recipes:\n")
|
||||
|
@ -87,6 +87,7 @@ mod string;
|
||||
mod subsequents;
|
||||
mod tempdir;
|
||||
mod undefined_variables;
|
||||
mod unstable;
|
||||
#[cfg(target_family = "windows")]
|
||||
mod windows_shell;
|
||||
mod working_directory;
|
||||
|
@ -234,7 +234,7 @@ impl Test {
|
||||
|
||||
if let Some(ref stdout_regex) = self.stdout_regex {
|
||||
if !stdout_regex.is_match(output_stdout) {
|
||||
panic!("Stdout regex mismatch:\n{output_stderr:?}\n!~=\n/{stdout_regex:?}/");
|
||||
panic!("Stdout regex mismatch:\n{output_stdout:?}\n!~=\n/{stdout_regex:?}/");
|
||||
}
|
||||
}
|
||||
|
||||
|
50
tests/unstable.rs
Normal file
50
tests/unstable.rs
Normal file
@ -0,0 +1,50 @@
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn set_unstable_true_with_env_var() {
|
||||
let justfile = r#"
|
||||
default:
|
||||
echo 'foo'
|
||||
"#;
|
||||
|
||||
for val in ["true", "some-arbitrary-string"] {
|
||||
Test::new()
|
||||
.justfile(justfile)
|
||||
.args(["--fmt"])
|
||||
.env("JUST_UNSTABLE", val)
|
||||
.status(EXIT_SUCCESS)
|
||||
.stderr_regex("Wrote justfile to `.*`\n")
|
||||
.run();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_unstable_false_with_env_var() {
|
||||
let justfile = r#"
|
||||
default:
|
||||
echo 'foo'
|
||||
"#;
|
||||
for val in ["0", "", "false"] {
|
||||
Test::new()
|
||||
.justfile(justfile)
|
||||
.args(["--fmt"])
|
||||
.env("JUST_UNSTABLE", val)
|
||||
.status(EXIT_FAILURE)
|
||||
.stderr("error: The `--fmt` command is currently unstable. Invoke `just` with the `--unstable` flag to enable unstable features.\n")
|
||||
.run();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_unstable_false_with_env_var_unset() {
|
||||
let justfile = r#"
|
||||
default:
|
||||
echo 'foo'
|
||||
"#;
|
||||
Test::new()
|
||||
.justfile(justfile)
|
||||
.args(["--fmt"])
|
||||
.status(EXIT_FAILURE)
|
||||
.stderr("error: The `--fmt` command is currently unstable. Invoke `just` with the `--unstable` flag to enable unstable features.\n")
|
||||
.run();
|
||||
}
|
Loading…
Reference in New Issue
Block a user