diff --git a/src/parser.rs b/src/parser.rs index e3abcbf..77c6147 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -339,6 +339,7 @@ impl<'run, 'src> Parser<'run, 'src> { } Some(Keyword::Import) if self.next_are(&[Identifier, StringToken]) + || self.next_are(&[Identifier, Identifier, StringToken]) || self.next_are(&[Identifier, QuestionMark]) => { self.presume_keyword(Keyword::Import)?; @@ -353,6 +354,7 @@ impl<'run, 'src> Parser<'run, 'src> { } Some(Keyword::Mod) 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, Eol]) || self.next_are(&[Identifier, QuestionMark]) => @@ -363,7 +365,8 @@ impl<'run, 'src> Parser<'run, 'src> { 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()?) } else { None diff --git a/tests/shell_expansion.rs b/tests/shell_expansion.rs index b748c50..f91fd00 100644 --- a/tests/shell_expansion.rs +++ b/tests/shell_expansion.rs @@ -65,3 +65,35 @@ fn shell_expanded_strings_can_be_used_in_settings() { .stdout("dotenv-value\n") .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(); +}