Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically create modules directory #2565

Merged
merged 8 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- Replace ModulePatch by ComponentPatch ([#2482](https://github.com/nf-core/tools/pull/2482))
- Fixed `nf-core modules lint` to work with new module structure for nf-test ([#2494](https://github.com/nf-core/tools/pull/2494))
- Add option `--migrate-pytest` to create a module with nf-test taking into account an existing module ([#2549](https://github.com/nf-core/tools/pull/2549))
- When installing modules and subworkflows, automatically create the `./modules` directory if it doesn't exist ([#2563](https://github.com/nf-core/tools/issues/2563))
- Modules `--migrate-pytest` copies template scripts ([#2568](https://github.com/nf-core/tools/pull/2568))

### Subworkflows
Expand Down
9 changes: 8 additions & 1 deletion nf_core/modules/modules_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import git
import questionary
import rich.prompt
from git.exc import GitCommandError

import nf_core.utils
Expand Down Expand Up @@ -68,7 +69,13 @@ def create(self):
new_modules_json = {"name": pipeline_name.strip("'"), "homePage": pipeline_url.strip("'"), "repos": {}}

if not self.modules_dir.exists():
raise UserWarning("Can't find a ./modules directory. Is this a DSL2 pipeline?")
if rich.prompt.Confirm.ask(
"[bold][blue]?[/] Can't find a ./modules directory. Would you like me to create one?", default=True
):
log.info(f"Creating ./modules directory in '{self.dir}'")
self.modules_dir.mkdir()
else:
raise UserWarning("Cannot proceed without a ./modules directory.")

# Get repositories
repos, _ = self.get_pipeline_module_repositories("modules", self.modules_dir)
Expand Down
Loading