mirror of
https://github.com/casey/just.git
synced 2025-12-23 11:37:29 +00:00
Stabilize [script] attribute
This commit is contained in:
parent
a4a363e709
commit
c7f9c49a4e
7 changed files with 6 additions and 90 deletions
|
|
@ -2973,10 +2973,6 @@ the value of `set shell`.
|
|||
The body of the recipe is evaluated, written to disk in the temporary
|
||||
directory, and run by passing its path as an argument to `COMMAND`.
|
||||
|
||||
The `[script(…)]` attribute is unstable, so you'll need to use `set unstable`,
|
||||
set the `JUST_UNSTABLE` environment variable, or pass `--unstable` on the
|
||||
command line.
|
||||
|
||||
### Script and Shebang Recipe Temporary Files
|
||||
|
||||
Both script and shebang recipes write the recipe body to a temporary file for
|
||||
|
|
|
|||
|
|
@ -158,17 +158,6 @@ impl<'run, 'src> Analyzer<'run, 'src> {
|
|||
aliases.insert(Self::resolve_alias(&self.modules, &recipes, alias)?);
|
||||
}
|
||||
|
||||
for recipe in recipes.values() {
|
||||
if recipe.attributes.contains(AttributeDiscriminant::Script) {
|
||||
unstable_features.insert(UnstableFeature::ScriptAttribute);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if settings.script_interpreter.is_some() {
|
||||
unstable_features.insert(UnstableFeature::ScriptInterpreterSetting);
|
||||
}
|
||||
|
||||
let source = root.to_owned();
|
||||
let root = paths.get(root).unwrap();
|
||||
|
||||
|
|
|
|||
|
|
@ -241,10 +241,6 @@ impl Display for CompileError<'_> {
|
|||
)
|
||||
}
|
||||
}
|
||||
ShebangAndScriptAttribute { recipe } => write!(
|
||||
f,
|
||||
"Recipe `{recipe}` has both shebang line and `[script]` attribute"
|
||||
),
|
||||
ShellExpansion { err } => write!(f, "Shell expansion failed: {err}"),
|
||||
RequiredParameterFollowsDefaultParameter { parameter } => write!(
|
||||
f,
|
||||
|
|
|
|||
|
|
@ -103,9 +103,6 @@ pub(crate) enum CompileErrorKind<'src> {
|
|||
RequiredParameterFollowsDefaultParameter {
|
||||
parameter: &'src str,
|
||||
},
|
||||
ShebangAndScriptAttribute {
|
||||
recipe: &'src str,
|
||||
},
|
||||
ShellExpansion {
|
||||
err: shellexpand::LookupError<env::VarError>,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1089,12 +1089,6 @@ impl<'run, 'src> Parser<'run, 'src> {
|
|||
let shebang = body.first().is_some_and(Line::is_shebang);
|
||||
let script = attributes.contains(AttributeDiscriminant::Script);
|
||||
|
||||
if shebang && script {
|
||||
return Err(name.error(CompileErrorKind::ShebangAndScriptAttribute {
|
||||
recipe: name.lexeme(),
|
||||
}));
|
||||
}
|
||||
|
||||
if attributes.contains(AttributeDiscriminant::WorkingDirectory)
|
||||
&& attributes.contains(AttributeDiscriminant::NoCd)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ use super::*;
|
|||
pub(crate) enum UnstableFeature {
|
||||
FormatSubcommand,
|
||||
LogicalOperators,
|
||||
ScriptAttribute,
|
||||
ScriptInterpreterSetting,
|
||||
WhichFunction,
|
||||
}
|
||||
|
||||
|
|
@ -17,10 +15,6 @@ impl Display for UnstableFeature {
|
|||
f,
|
||||
"The logical operators `&&` and `||` are currently unstable."
|
||||
),
|
||||
Self::ScriptAttribute => write!(f, "The `[script]` attribute is currently unstable."),
|
||||
Self::ScriptInterpreterSetting => {
|
||||
write!(f, "The `script-interpreter` setting is currently unstable.")
|
||||
}
|
||||
Self::WhichFunction => write!(f, "The `which()` function is currently unstable."),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,36 +1,10 @@
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn unstable() {
|
||||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
[script('sh', '-u')]
|
||||
foo:
|
||||
echo FOO
|
||||
",
|
||||
)
|
||||
.stderr_regex(r"error: The `\[script\]` attribute is currently unstable\..*")
|
||||
.status(EXIT_FAILURE)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn script_interpreter_setting_is_unstable() {
|
||||
Test::new()
|
||||
.justfile("set script-interpreter := ['sh']")
|
||||
.status(EXIT_FAILURE)
|
||||
.stderr_regex(r"error: The `script-interpreter` setting is currently unstable\..*")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runs_with_command() {
|
||||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
set unstable
|
||||
|
||||
[script('cat')]
|
||||
foo:
|
||||
FOO
|
||||
|
|
@ -40,8 +14,6 @@ fn runs_with_command() {
|
|||
"
|
||||
|
||||
|
||||
|
||||
|
||||
FOO
|
||||
",
|
||||
)
|
||||
|
|
@ -53,8 +25,6 @@ fn no_arguments() {
|
|||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
set unstable
|
||||
|
||||
[script('sh')]
|
||||
foo:
|
||||
echo foo
|
||||
|
|
@ -69,8 +39,6 @@ fn with_arguments() {
|
|||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
set unstable
|
||||
|
||||
[script('sh', '-x')]
|
||||
foo:
|
||||
echo foo
|
||||
|
|
@ -82,28 +50,22 @@ fn with_arguments() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn not_allowed_with_shebang() {
|
||||
fn allowed_with_shebang() {
|
||||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
set unstable
|
||||
|
||||
[script('sh', '-u')]
|
||||
[script('cat')]
|
||||
foo:
|
||||
#!/bin/sh
|
||||
|
||||
",
|
||||
)
|
||||
.stderr(
|
||||
.stdout(
|
||||
"
|
||||
error: Recipe `foo` has both shebang line and `[script]` attribute
|
||||
——▶ justfile:4:1
|
||||
│
|
||||
4 │ foo:
|
||||
│ ^^^
|
||||
|
||||
|
||||
#!/bin/sh
|
||||
",
|
||||
)
|
||||
.status(EXIT_FAILURE)
|
||||
.run();
|
||||
}
|
||||
|
||||
|
|
@ -112,8 +74,6 @@ fn script_line_numbers() {
|
|||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
set unstable
|
||||
|
||||
[script('cat')]
|
||||
foo:
|
||||
FOO
|
||||
|
|
@ -125,8 +85,6 @@ fn script_line_numbers() {
|
|||
"
|
||||
|
||||
|
||||
|
||||
|
||||
FOO
|
||||
|
||||
BAR
|
||||
|
|
@ -140,8 +98,6 @@ fn script_line_numbers_with_multi_line_recipe_signature() {
|
|||
Test::new()
|
||||
.justfile(
|
||||
r"
|
||||
set unstable
|
||||
|
||||
[script('cat')]
|
||||
foo bar='baz' \
|
||||
:
|
||||
|
|
@ -161,8 +117,6 @@ fn script_line_numbers_with_multi_line_recipe_signature() {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
FOO
|
||||
|
||||
BAR
|
||||
|
|
@ -325,8 +279,6 @@ fn no_arguments_with_default_script_interpreter() {
|
|||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
set unstable
|
||||
|
||||
[script]
|
||||
foo:
|
||||
case $- in
|
||||
|
|
@ -352,8 +304,6 @@ fn no_arguments_with_non_default_script_interpreter() {
|
|||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
set unstable
|
||||
|
||||
set script-interpreter := ['sh']
|
||||
|
||||
[script]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue