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

feat: find files func in prep for auto detection #886

Merged
merged 1 commit into from
Dec 6, 2019

Conversation

gitphill
Copy link
Contributor

  • Ready for review
  • Follows CONTRIBUTING rules
  • Reviewed by Snyk internal team

What does this PR do?

Added find-files module with find function to help search for files.
Added test for find and test fixtures.

How should this be manually tested?

Just helper function at the moment, separate PR to integrate with CLI commands and auto detection.

What are the relevant tickets?

BST-1072

@gitphill gitphill requested a review from a team November 28, 2019 09:40
@gitphill gitphill self-assigned this Nov 28, 2019
@ghost ghost requested review from lwywoo and miiila November 28, 2019 09:40
const stats = await getStats(searchPath);
if (stats.isDirectory()) {
const paths = await readDirectory(searchPath);
for (const subPath of paths) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to do this asynchronously for found paths?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand, could you elaborate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think she is saying you can do Promise.all() instead of for loop (maybe with a pMap to reduce concurrency)

const found: string[] = [];
try {
const stats = await getStats(searchPath);
if (stats.isDirectory()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whole function is quite hard to read with so many if else, maybe split it up and return early where possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea I'll take a look, it is a bit intricate😃

): Promise<string[]> {
const found: string[] = [];
try {
const stats = await getStats(searchPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe filePathStats to be more explicit?

@gitphill gitphill force-pushed the feat/helper-to-find-files branch 2 times, most recently from 386417d to e87c2ac Compare December 6, 2019 10:28
Added find-files module with find function to help search for files.
Added test for find and test fixtures.
Ignore node_modules in sub directories or as given path.

Co-authored-by: Lili Kastilio <lili@lilianakastilio.co.uk>
@gitphill gitphill merged commit bbc0111 into master Dec 6, 2019
@gitphill gitphill deleted the feat/helper-to-find-files branch December 6, 2019 17:41
@snyksec
Copy link

snyksec commented Dec 6, 2019

🎉 This PR is included in version 1.258.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants