diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dfedd022f..560df29775 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/nf_core/modules/modules_json.py b/nf_core/modules/modules_json.py index 8423f1075c..ee912843b6 100644 --- a/nf_core/modules/modules_json.py +++ b/nf_core/modules/modules_json.py @@ -10,6 +10,7 @@ import git import questionary +import rich.prompt from git.exc import GitCommandError import nf_core.utils @@ -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)