Allow shell expanded strings in mod and import paths (#2059)
This commit is contained in:
parent
a343f5c80c
commit
198b37c020
@ -339,6 +339,7 @@ impl<'run, 'src> Parser<'run, 'src> {
|
|||||||
}
|
}
|
||||||
Some(Keyword::Import)
|
Some(Keyword::Import)
|
||||||
if self.next_are(&[Identifier, StringToken])
|
if self.next_are(&[Identifier, StringToken])
|
||||||
|
|| self.next_are(&[Identifier, Identifier, StringToken])
|
||||||
|| self.next_are(&[Identifier, QuestionMark]) =>
|
|| self.next_are(&[Identifier, QuestionMark]) =>
|
||||||
{
|
{
|
||||||
self.presume_keyword(Keyword::Import)?;
|
self.presume_keyword(Keyword::Import)?;
|
||||||
@ -353,6 +354,7 @@ impl<'run, 'src> Parser<'run, 'src> {
|
|||||||
}
|
}
|
||||||
Some(Keyword::Mod)
|
Some(Keyword::Mod)
|
||||||
if self.next_are(&[Identifier, Identifier, StringToken])
|
if self.next_are(&[Identifier, Identifier, StringToken])
|
||||||
|
|| self.next_are(&[Identifier, Identifier, Identifier, StringToken])
|
||||||
|| self.next_are(&[Identifier, Identifier, Eof])
|
|| self.next_are(&[Identifier, Identifier, Eof])
|
||||||
|| self.next_are(&[Identifier, Identifier, Eol])
|
|| self.next_are(&[Identifier, Identifier, Eol])
|
||||||
|| self.next_are(&[Identifier, QuestionMark]) =>
|
|| self.next_are(&[Identifier, QuestionMark]) =>
|
||||||
@ -363,7 +365,8 @@ impl<'run, 'src> Parser<'run, 'src> {
|
|||||||
|
|
||||||
let name = self.parse_name()?;
|
let name = self.parse_name()?;
|
||||||
|
|
||||||
let relative = if self.next_is(StringToken) {
|
let relative = if self.next_is(StringToken) || self.next_are(&[Identifier, StringToken])
|
||||||
|
{
|
||||||
Some(self.parse_string_literal()?)
|
Some(self.parse_string_literal()?)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -65,3 +65,35 @@ fn shell_expanded_strings_can_be_used_in_settings() {
|
|||||||
.stdout("dotenv-value\n")
|
.stdout("dotenv-value\n")
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn shell_expanded_strings_can_be_used_in_import_paths() {
|
||||||
|
Test::new()
|
||||||
|
.justfile(
|
||||||
|
"
|
||||||
|
import x'$JUST_TEST_VARIABLE'
|
||||||
|
|
||||||
|
foo: bar
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.write("import.just", "@bar:\n echo BAR")
|
||||||
|
.env("JUST_TEST_VARIABLE", "import.just")
|
||||||
|
.stdout("BAR\n")
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn shell_expanded_strings_can_be_used_in_mod_paths() {
|
||||||
|
Test::new()
|
||||||
|
.justfile(
|
||||||
|
"
|
||||||
|
mod foo x'$JUST_TEST_VARIABLE'
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.write("mod.just", "@bar:\n echo BAR")
|
||||||
|
.env("JUST_TEST_VARIABLE", "mod.just")
|
||||||
|
.args(["--unstable", "foo", "bar"])
|
||||||
|
.stdout("BAR\n")
|
||||||
|
.test_round_trip(false)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user