Skip to content

Commit

Permalink
run pre-commit from a git repo
Browse files Browse the repository at this point in the history
  • Loading branch information
mirpedrol committed Dec 13, 2024
1 parent f6159c9 commit 9f61e85
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions nf_core/pipelines/create/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ def init_pipeline(self):
# Init the git repository and make the first commit
if not self.no_git:
self.git_init_pipeline()
# Run prettier on files
current_dir = Path.cwd()
os.chdir(self.outdir)
run_prettier_on_file([str(f) for f in self.outdir.glob("**/*")])
os.chdir(current_dir)

if self.config.is_nfcore and not self.is_interactive:
log.info(
Expand Down Expand Up @@ -378,9 +383,6 @@ def render_template(self) -> None:
yaml.safe_dump(config_yml.model_dump(exclude_none=True), fh)
log.debug(f"Dumping pipeline template yml to pipeline config file '{config_fn.name}'")

# Run prettier on files
run_prettier_on_file([str(f) for f in self.outdir.glob("**/*")])

def fix_linting(self):
"""
Updates the .nf-core.yml with linting configurations
Expand Down
2 changes: 1 addition & 1 deletion nf_core/pipelines/lint_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def run_prettier_on_file(file: Union[Path, str, List[str]]) -> None:
all_lines = [line for line in e.stdout.decode().split("\n")]
files = "\n".join(all_lines[3:])
log.debug(f"The following files were modified by prettier:\n {files}")
elif e.stderr.decode():
else:
log.warning(
"There was an error running the prettier pre-commit hook.\n"
f"STDOUT: {e.stdout.decode()}\nSTDERR: {e.stderr.decode()}"
Expand Down

0 comments on commit 9f61e85

Please sign in to comment.