diff --git a/bake/bakefile.py b/bake/bakefile.py index f9092f6..b502668 100644 --- a/bake/bakefile.py +++ b/bake/bakefile.py @@ -144,6 +144,8 @@ class TaskScript(BaseAction): if line.startswith(indent_style): return line[len(indent_style) :] + return line + def temp_source(self): tf = mkstemp(suffix=".sh", prefix="bashf-")[1] @@ -170,17 +172,27 @@ class TaskScript(BaseAction): script = shlex_quote(f"{tf} {args} 2>&1 | bake-indent") cmd = f"bash --init-file {shlex_quote(stdlib_path)} -i -c {script}" + return_code = os.system(cmd) + if debug: click.echo(f"$ {cmd}", err=True) + else: + os.remove(tf) - return os.system(cmd) + return return_code def shellcheck(self, *, silent=False, debug=False, **kwargs): tf = self.temp_source() cmd = f"shellcheck {shlex_quote(tf)} --external-sources --format=json" + + c = delegator.run(cmd) + if debug: click.echo(f"$ {cmd}", err=True) - return delegator.run(cmd) + else: + os.remove(tf) + + return c @property def name(self): diff --git a/bake/tests/fixtures/1.Bakefile b/bake/tests/fixtures/1.Bakefile index ce9b604..7d05e53 100644 --- a/bake/tests/fixtures/1.Bakefile +++ b/bake/tests/fixtures/1.Bakefile @@ -2,9 +2,12 @@ test1: test2 test3 source ./ test2: test3 echo '2' -test3: - echo '3' +test3: echo + echo 'hm' +python: + #!/usr/bin/env python + print('wow!') echo: echo 'hi, kenneth!' diff --git a/bake/tests/test_bakefile.py b/bake/tests/test_bakefile.py index 425d313..5306517 100644 --- a/bake/tests/test_bakefile.py +++ b/bake/tests/test_bakefile.py @@ -11,3 +11,8 @@ def test_first_level_dep(bake): def test_second_level_dep(bake): c = bake("needs-needs", fixture="1") assert "kenneth" in c.out + + +def test_python_invocation(bake): + c = bake("python", fixture="1") + assert "wow" in c.out diff --git a/bake/tests/test_sourcing.py b/bake/tests/test_sourcing.py new file mode 100644 index 0000000..e69de29