Skip to content

Commit

Permalink
Merge pull request #2565 from krokicki/create_modules_dir
Browse files Browse the repository at this point in the history
Automatically create modules directory
  • Loading branch information
mirpedrol authored Dec 15, 2023
2 parents 8bab0f1 + 2673ce9 commit 9414faf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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))
- When `.nf-core.yml` is not found create it in the current directory instead of the root filesystem ([#2237](https://github.com/nf-core/tools/issues/2237))
- Modules `--migrate-pytest` copies template scripts ([#2568](https://github.com/nf-core/tools/pull/2568))

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

0 comments on commit 9414faf

Please sign in to comment.