Skip to content

Commit 1e3a7da

Browse files
authored
Merge pull request nf-core#3633 from nf-core/module_exec
Support modules with `exec:` blocks
2 parents 9bff2b9 + 2872af9 commit 1e3a7da

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
### Modules
1010

11+
- Support modules with `exec:` blocks ([#3633](https://github.com/nf-core/tools/pull/3633))
1112
- feat: nf-core modules bump-version supports specifying the toolkit ([#3608](https://github.com/nf-core/tools/pull/3608))
1213

1314
### Subworkflows

nf_core/modules/lint/main_nf.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def main_nf(
9090
process_lines = []
9191
script_lines = []
9292
shell_lines = []
93+
exec_lines = []
9394
when_lines = []
9495
iter_lines = iter(lines)
9596
for line in iter_lines:
@@ -110,6 +111,9 @@ def main_nf(
110111
if re.search(r"^\s*shell\s*:", line) and state in ["input", "output", "when", "process"]:
111112
state = "shell"
112113
continue
114+
if re.search(r"^\s*exec\s*:", line) and state in ["input", "output", "when", "process"]:
115+
state = "exec"
116+
continue
113117

114118
# Perform state-specific linting checks
115119
if state == "process" and not _is_empty(line):
@@ -132,6 +136,8 @@ def main_nf(
132136
script_lines.append(line)
133137
if state == "shell" and not _is_empty(line):
134138
shell_lines.append(line)
139+
if state == "exec" and not _is_empty(line):
140+
exec_lines.append(line)
135141

136142
# Check that we have required sections
137143
if not len(outputs):
@@ -149,8 +155,10 @@ def main_nf(
149155
check_when_section(module, when_lines)
150156

151157
# Check that we have script or shell, not both
152-
if len(script_lines) and len(shell_lines):
153-
module.failed.append(("main_nf_script_shell", "Script and Shell found, should use only one", module.main_nf))
158+
if sum(bool(block_lines) for block_lines in (script_lines, shell_lines, exec_lines)) > 1:
159+
module.failed.append(
160+
("main_nf_script_shell", "Multiple script:/shell:/exec: blocks found, should use only one", module.main_nf)
161+
)
154162

155163
# Check the script definition
156164
if len(script_lines):

0 commit comments

Comments
 (0)