Commit 1d4f4a0d by Branch Vincent Committed by GitHub

fix(run): improve error when command not found (#5243)

parent ea6e189a
...@@ -29,7 +29,11 @@ class RunCommand(EnvCommand): ...@@ -29,7 +29,11 @@ class RunCommand(EnvCommand):
if scripts and script in scripts: if scripts and script in scripts:
return self.run_script(scripts[script], args) return self.run_script(scripts[script], args)
return self.env.execute(*args) try:
return self.env.execute(*args)
except FileNotFoundError:
self.line_error(f"<error>Command not found: <c1>{script}</c1></error>")
return 1
@property @property
def _module(self) -> "Module": def _module(self) -> "Module":
......
...@@ -37,3 +37,14 @@ def test_run_keeps_options_passed_before_command( ...@@ -37,3 +37,14 @@ def test_run_keeps_options_passed_before_command(
app_tester.application.long_version + "\n" app_tester.application.long_version + "\n"
) )
assert [] == env.executed assert [] == env.executed
def test_run_has_helpful_error_when_command_not_found(
app_tester: "ApplicationTester", env: "MockEnv"
):
env._execute = True
app_tester.execute("run nonexistent-command")
assert env.executed == [["nonexistent-command"]]
assert app_tester.status_code == 1
assert app_tester.io.fetch_error() == "Command not found: nonexistent-command\n"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment