Skip to content

Commit

Permalink
run prettier also for subworkflows
Browse files Browse the repository at this point in the history
  • Loading branch information
mirpedrol committed Dec 2, 2022
1 parent 0e0293f commit 3d9329b
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions nf_core/subworkflows/test_yml_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from nf_core.modules.modules_json import ModulesJson
from nf_core.modules.modules_repo import ModulesRepo

from ..lint_utils import run_prettier_on_file

log = logging.getLogger(__name__)


Expand Down Expand Up @@ -374,16 +376,19 @@ def print_test_yml(self):
"""
Generate the test yml file.
"""
with tempfile.NamedTemporaryFile(mode="w+") as fh:
yaml.dump(self.tests, fh, Dumper=nf_core.utils.custom_yaml_dumper(), width=10000000)
run_prettier_on_file(fh.name)
fh.seek(0)
prettified_yml = fh.read()

if self.test_yml_output_path == "-":
console = rich.console.Console()
yaml_str = yaml.dump(self.tests, Dumper=nf_core.utils.custom_yaml_dumper(), width=10000000)
console.print("\n", Syntax(yaml_str, "yaml"), "\n")
return

try:
log.info(f"Writing to '{self.test_yml_output_path}'")
with open(self.test_yml_output_path, "w") as fh:
yaml.dump(self.tests, fh, Dumper=nf_core.utils.custom_yaml_dumper(), width=10000000)
except FileNotFoundError as e:
raise UserWarning(f"Could not create test.yml file: '{e}'")
console.print("\n", Syntax(prettified_yml, "yaml"), "\n")
else:
try:
log.info(f"Writing to '{self.test_yml_output_path}'")
with open(self.test_yml_output_path, "w") as fh:
fh.write(prettified_yml)
except FileNotFoundError as e:
raise UserWarning(f"Could not create test.yml file: '{e}'")

0 comments on commit 3d9329b

Please sign in to comment.