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

Add wrapper functions for getAllFilesFromDir with named parameters #18

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

lukfor
Copy link
Contributor

@lukfor lukfor commented Oct 2, 2024

Hi all,

First of all, thank you for collecting all the nice snippets in one plugin. I really appreciate your effort! I believe having an independent plugin separate from the nf-test releases helps to incorporate changes more quickly.

I noticed that the Hackathon has its own nf-test plugin group. That’s wonderful to hear! 🚀

This PR adds a wrapper to the getAllFilesFromDir function and utilizes named parameters (a concept frequently used in Nextflow). I think this could serve as a good boilerplate to demonstrate how this approach can be implemented. It improves code readability and allows for the inclusion of additional optional parameters with default values, without making the method signature unreadable.

Example:

def stable_name  = getAllFilesFromDir(params.outdir, ignore: ['pipeline_info/execution_*.{html,txt}'])
def stable_content = getAllFilesFromDir(params.outdir, includeDir: false, ignore: ['pipeline_info/execution_*.{html,txt}'], ignoreFile: 'tests/getAllFilesFromDir/.nftignore')
assert snapshot(
  // Only snapshot name
  stable_name*.name,
  // Snapshot content
  stable_content
).match()

//with default params and relative
println(getAllFilesFromDir(params.outdir))
println(getAllFilesFromDir(params.outdir, relative: true))

I also included a relative option to combine it with getRelativePath(..).

Hope this helps and thanks guys! 🚀🙏

@maxulysse maxulysse merged commit 10581d1 into nf-core:main Oct 2, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants